Systemd Service — Best Practices
Cấu trúc cơ bản
[Unit]
Description=My Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/myapp
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Best practices
- Luôn set
Restart=on-failure - Dùng
ExecStartPrecho health check LimitNOFILEnếu service dùng nhiều kết nối