I could not find any examples of this out there, so here is what I’ve come up with for running the concourse worker binary with systemd.
In my scenario I’m using an Azure Scale Set configured to auto-scale and I kept ending up with with workers in a stalled state. Using this unit file the workers clean things up before exiting the system.
The key parts are:
# Manage the process with signals KillMode=process # On system shutdown (or `systemctl stop`) retire the worker. KillSignal=SIGUSR2 # On restart just land the worker. RestartKillSignal=SIGUSR1 # Arbitrarily wait 5 minutes for worker to drain. TimeoutStopSec=300
The full unit I’m using at the moment (tips/adjustments welcome):
[Unit] Description=Concourse Worker [Service] ExecStart=/usr/local/concourse/bin/concourse worker User=root Group=root Type=simple WorkingDirectory=/opt/concourse/worker # These settings were yanked out of the concourse test setup in some github # repo, they may be wrong for production. LimitNPROC=infinity LimitNOFILE=infinity TasksMax=infinity MemoryLimit=infinity Delegate=yes # They key bits RestartSec=5 Restart=on-failure RestartKillSignal=SIGUSR1 KillMode=process KillSignal=SIGUSR2 TimeoutStopSec=300 # ... other config omitted [Install] WantedBy=multi-user.target