3 ms·
What is wrong with it exactly? A typical unit file would for something that runs forever is something like this: [Unit] Description=This service runs a
by jononor 7y ago
What is wrong with it exactly? A typical unit file would for something that runs forever is something like this:
[Unit]
Description=This service runs always
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=/usr/bin/python3 /opt/myapp/main.py
Restart=always
WorkingDirectory=/opt/myapp
User=myuser
Group=myuser
You can skip the last 3 if you want.
- Arnavion 7y agoIf main.py crashes ~5 times within ~10 seconds, then it'll get put in a failed state until you manually recover it with `reset-failed`. systemd will be happy to restart it often enough that it hits that threshold, because you told it to. So just `Restart=always` isn't enough; you need to set `StartLimitBurst` too (and `StartLimitIntervalSec` if you want to fine-tune it).
- jjoonathan 7y agoThe systemd unit file isn't a cluster of half-baked utilities held together with spit and bailing wire, so naturally people hate it.