Systemd je init systém na většině moderních distribucí. Jednotný způsob správy procesů, služeb a logů.
Základní příkazy¶
systemctl start|stop|restart|reload|status nginx systemctl enable|disable nginx systemctl list-units –type=service –state=failed
Vlastní služba¶
[Unit] Description=Moje aplikace After=network.target postgresql.service [Service] Type=simple User=app WorkingDirectory=/opt/myapp ExecStart=/opt/myapp/bin/server –port 8080 Restart=on-failure RestartSec=5 EnvironmentFile=/opt/myapp/.env [Install] WantedBy=multi-user.target systemctl daemon-reload systemctl enable –now myapp
Resource limity¶
[Service] CPUQuota=200% MemoryMax=2G LimitNOFILE=65535 ProtectSystem=strict PrivateTmp=yes
Debugging¶
systemctl status myapp -l journalctl -u myapp –since ‘5 min ago’ systemd-analyze blame
Systemd je standard¶
Naučte se unit soubory, závislosti a resource limity.