usr

Docs

Settings

Everything is configured with environment variables, usually from /etc/default/usr.

VariableDefaultMeaning
USR_URLhttp://127.0.0.1:8080/healthURL that must answer with a 2xx status.
USR_CMDsystemctl reload myappCommand to run after too many failures.
USR_FAILS3Failed checks in a row before reloading.
USR_TIMEOUT5Seconds to wait for the health URL.
USR_STATE/run/usr.countWhere 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.