Docs
Settings
Everything is configured with environment variables, usually from /etc/default/usr.
| Variable | Default | Meaning |
|---|---|---|
USR_URL | http://127.0.0.1:8080/health | URL that must answer with a 2xx status. |
USR_CMD | systemctl reload myapp | Command to run after too many failures. |
USR_FAILS | 3 | Failed checks in a row before reloading. |
USR_TIMEOUT | 5 | Seconds to wait for the health URL. |
USR_STATE | /run/usr.count | Where the failure counter is kept. |
systemd timer
# /etc/systemd/system/usr.service
[Unit]
Description=uptime server reloader check
[Service]
Type=oneshot
EnvironmentFile=-/etc/default/usr
ExecStart=/usr/local/bin/usr
# /etc/systemd/system/usr.timer
[Unit]
Description=run usr every minute
[Timer]
OnBootSec=2min
OnUnitActiveSec=1min
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now usr.timer
journalctl -t usr -f
Example: gunicorn app behind nginx
# /etc/default/usr
USR_URL=http://127.0.0.1:8000/healthz
USR_CMD="systemctl restart myapp"
USR_FAILS=2
Prefer reload when your service supports it; a restart drops in-flight requests.