Have graceful termination out of the box for gitlab-runner install
Overview
When you run gitlab-runner install inside of a Linux machine this creates a systemd service gitlab-runner.service with the contents below:
cat /etc/systemd/system/gitlab-runner.service
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/gitlab-runner
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "gitlab-runner"
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
By default systemd sends a SIGTERM which requires used to create a drop-in file with the following content since gitlab-runner doesn't understand SIGTERM but understand SIGQUIT for graceful termination.
[Service]
TimeoutStopSec=7200
KillSignal=SIGQUIT
Proposal
There are two things that we can do:
- Have
gitlab-runnerlisten toSIGTERMas well for graceful termination. - Specify
KillSignal=SIGQUITwhen you rungitlab-runner installon a Linux machine so that it's terminated gracefully by default.