# Poll for a new release every five minutes.
#
#   install: /etc/systemd/system/pig-autodeploy.timer
#   enable:  systemctl enable --now pig-autodeploy.timer
#
# Five minutes is the lag between tagging a release and it being live, on top
# of however long CI takes to publish the image. That is the price of the host
# pulling rather than CI pushing, and it is a fair one.

[Unit]
Description=PIG — poll the registry for a new release
Documentation=https://git.karti.ai/PIG/pig/src/branch/main/deploy/README.md

[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
# Without this every PIG host in a fleet would poll on the same second.
RandomizedDelaySec=60
AccuracySec=30s
# Deliberately NOT Persistent=true. Catching up a missed poll after a long
# downtime would deploy at boot, which is precisely when a human is least
# likely to be watching.
Unit=pig-autodeploy.service

[Install]
WantedBy=timers.target
