Self-Updating Linux Service with Health-Gated Rollback
A systemd service that fetches its own new release, switches symlinks atomically and rolls back on a failed probe.
- Runs out of the box: yes
- Tests: no
- CI: no
- Docs: yes
- Used in production: no
Learning demo, not turnkey. This example is experimental: it shows an idea that works on the bench, but it has not been reviewed for production use. Expect rough edges and check with the owner before reusing it.
Purpose#
For internal services that run on a handful of servers without an orchestrator. A timer fetches a release manifest, unpacks the new version beside the old one, flips a symlink and restarts the service. A readiness probe decides within a time limit whether to keep the new version or flip back.
The release layout keeps the last two versions on disk so a rollback is a symlink flip and a restart rather than a download.
Technologies & features#
- Technologies
- BashLinuxDocker
- Features
- Automatic UpdateHealth Check
- Topics
- Update DeliveryprimaryDeployment & Infrastructure
Lessons learned#
- Worked
Keeping two versions on disk made rollback nearly instant and removed the need for a network during a failed update.
- Didn’t work
A readiness probe that only checked the process was running passed on a build that could not reach its database. The probe now exercises one real request.
Try it#
git clone https://git.example.internal/platform-ops/self-update-service.git
cd self-update-service
sudo ./install.sh --manifest https://releases.example.internal/demo/manifest.json
systemctl status demo-updater.timerCommands come from the owner’s README. Credentials are never stored here.




