Background loop that pulls origin/main periodically and rebuilds the
validator container when new commits land. Uses the same docker compose
mechanism the main README documents (section 5.1) so it works for any
validator following the standard setup.
- Polls
origin/mainevery 5 minutes (configurable viaAUTOUPDATE_INTERVAL) - On new commits:
git reset --hard origin/mainthendocker compose up -d --build - Logs to stdout — pipe to a log file or rely on systemd/journald
./scripts/autoupdate.shYou need to keep this script running across machine reboots. Pick whichever fits your setup.
Create /etc/systemd/system/blockmachine-autoupdate.service:
[Unit]
Description=BlockMachine validator autoupdate
After=docker.service network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=/path/to/blockmachine-validator
ExecStart=/path/to/blockmachine-validator/scripts/autoupdate.sh
Restart=on-failure
RestartSec=30
User=YOUR_USER
# Environment overrides (optional):
# Environment=AUTOUPDATE_INTERVAL=300
# Environment=AUTOUPDATE_BRANCH=main
[Install]
WantedBy=multi-user.targetThen:
sudo systemctl daemon-reload
sudo systemctl enable --now blockmachine-autoupdate
sudo journalctl -u blockmachine-autoupdate -fcrontab -e
# Add:
@reboot cd /path/to/blockmachine-validator && nohup ./scripts/autoupdate.sh >> /var/log/bm-autoupdate.log 2>&1 &You'll also want to start it the first time without a reboot:
nohup ./scripts/autoupdate.sh >> /var/log/bm-autoupdate.log 2>&1 &tmux new -d -s autoupdate './scripts/autoupdate.sh'
# Detach: Ctrl-b d. Reattach: tmux attach -t autoupdateThis won't survive reboots — combine with @reboot cron if needed.
| Variable | Default | What it does |
|---|---|---|
AUTOUPDATE_INTERVAL |
300 | Seconds between update checks |
AUTOUPDATE_BRANCH |
main | Branch to track (override for forks) |
- The script does
git reset --hard origin/main. Don't hand-edit files in the repo while the autoupdater is running — your changes will be discarded on the next pull. - Postgres data is preserved across rebuilds (it's in a Docker volume).
- The first thing the script does on startup is run
docker compose up -d --build. After a machine reboot, the validator container will already be running viarestart: unless-stopped, but this initial pass also picks up any commits that landed while the machine was offline. - If a build fails, the previous container keeps running and the script retries on the next cycle.