Systemd Service — Best Practices
Cấu trúc cơ bản
1[Unit]
2Description=My Service
3After=network-online.target
4Wants=network-online.target
5
6[Service]
7Type=simple
8ExecStart=/usr/local/bin/myapp
9Restart=on-failure
10RestartSec=5
11
12[Install]
13WantedBy=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