Scheduling & Self-heal¶
Pypen has two layers of "keep it running" logic:
- s6-overlay handles crash-restart at the process level. If a worker exits,
s6restarts it within seconds. - app/cron.py handles scheduled restarts — the kind you want for long-running scripts that "go bad" after a while (memory leaks, stale connections, expired tokens).
Periodic Restarts — restart_on¶
Restart the worker every N hours. Useful for bots and scrapers whose process state drifts over time.
[project.cron] restart_on = "6" # restart every 6 hours
Hard Redeploys — redeploy¶
When redeploy = "true", a scheduled restart also wipes and
rebuilds the venv. Use it when a project's dependencies change often
and you want each restart to pick up the latest pinned versions.
Idle Restarts — idle¶
idle = "10" auto-starts a worker after 10 minutes of
inactivity (no log output). This is handy for jobs that are supposed to
"always be talking" — if they go quiet, something is wrong, so
bounce them.
Pull-on-restart — pull_commits¶
With pull_commits = "true" (the default), every restart is
preceded by git pull. Combined with restart_on
this gives you a poor-man's continuous deployment: push to
main, wait at most N hours, the new code is live.
Self-heal Behaviour¶
Crash-loops are absorbed by s6-overlay. If a worker is
crashing repeatedly, the dashboard surfaces it with a red status; you
can stop or rebuild it from the UI without restarting the whole
container.
Recommended starting point
For typical bots: restart_on = "12",
redeploy = "false", idle = "",
pull_commits = "true". Tighten from there if you observe
drift.