Gracefully stop long running processes when using the shell executor
- Stop adding
--user
togitlab-runner run
command:
When --user
is included in the gitlab-runner run
invocation AND a shell-executor is being used, scripts are run using su
to assume the specified users identity. This fact alone prevents graceful shutdown of long-running processes, and indeed stopping of such processes altogether. This is because when a job is cancelled or times out, SIGTERM is sent to the su
process, which exits, leaving orphaned it's entire child process tree. --user
is added to the run
command when also specified in install
command. However, there's a different way to run runner as a specific user, and that is to configure the init system to run the serve under the specified user. This change does that.
- Set saner default for --config option:
With the change in the previous commit, the existing default config path no longer works. Since the default config path now depends on the specified user, we can't set it statically anymore. We have to evaluate it dynamically based on the specified user. The alternative is to ONLY mention this in the documentation.