Teamcity Build Agent gets killed by systemd when upgrading
On our centos system we have configured a teamcity agent as a systemd service. The service works fine except when the agent performs an upgrade. Then it gets killed while performing the upgrade. I guess this is due to the fact, that systemd watches the created processes and when the main process exists to let a second process perform an upgrade systemd decides this is a lost process and kills it after about a minute.
I guess this assumption gets validated by the fact that when i directly start the teamcity agent the upgrade works without a problem.
This is the configuration of the service:
[Unit]
Description=teamcity agent - local
Requires=network.target
After=network.target
[Service]
Type=forking
PIDFile=/home/teamcityagent/logs/buildAgent.pid
WorkingDirectory=/home/teamcityagent
User=teamcityagent
Group=teamcityagent
ExecStart=/home/teamcityagent/bin/agent.sh start
ExecStop=/home/teamcityagent/bin/agent.sh stop
TimeoutStartSec=900
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
So far I have tried to change the timeout to 900secs and commented out the PIDFile. Nothing helped.
Is there a way to tell systemd to not kill the upgrade process by telling it not to watch for lost processes?
Adding
RemainAfterExit=yes
to the Service
stanza appears to fix this without needing to change timeouts.
Documented at https://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit=