[Unit] # One instance of a rolling update. Copy to /etc/systemd/system/junction@.service and # keep one configuration per colour, e.g. /etc/junction/junction-blue.conf: # # systemctl start junction@blue # new binary, same port # systemctl stop junction@green # old instance drains, then exits # # That only works with so_reuseport on in the configuration: without it the new instance # cannot bind while the old one is still holding the port, and the update has a window # with no listener at all. Description=junction instance %i — model router After=network-online.target Wants=network-online.target StartLimitIntervalSec=0 StartLimitBurst=0 [Service] Type=simple User=lotherk Group=lotherk Environment=HOME=/home/lotherk # The cloud key lives in Hermes' .env; junction only reads it from the environment and # never logs it. EnvironmentFile=/home/lotherk/.hermes/.env EnvironmentFile=-/etc/junction/junction.env # Separate runtime directories per instance, so the control sockets do not collide: # /run/junction/blue, /run/junction/green. Without this the second instance cannot # create its socket and silently serves TCP only. RuntimeDirectory=junction/%i RuntimeDirectoryMode=0750 ExecStart=/usr/local/bin/junction --config /etc/junction/junction-%i.conf # SIGTERM is not a kill switch here: junction closes the listening socket, finishes the # running requests and exits. Give it the drain timeout plus a little room before # systemd escalates. TimeoutStopSec=40 Restart=always RestartSec=3 [Install] WantedBy=multi-user.target