init.md 2.12 KB
Newer Older
1 2 3 4 5 6
---
stage: Verify
group: Runner
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---

7 8 9 10 11 12
# The system services of GitLab Runner

GitLab Runner uses the [Go `service` library](https://github.com/kardianos/service)
to detect the underlying OS and eventually install the service file based on
the init system.

13
NOTE:
14 15 16
`service` installs, un-installs, starts, stops, and runs a program as a
service (daemon). Windows XP+, Linux/(systemd | Upstart | SysV),
and macOS/Launchd are supported.
17

18 19
When GitLab Runner [is installed](../install/index.md), the service file is
automatically created:
20 21 22 23 24 25 26 27

- **systemd:** `/etc/systemd/system/gitlab-runner.service`
- **upstart:** `/etc/init/gitlab-runner`

## Overriding the default service files

In some cases, you might want to override the default behavior of the service.

28 29
For example, when you upgrade GitLab Runner, you should stop it gracefully
until all running jobs are finished. However, systemd, upstart, or other services
30 31
may almost immediately restart the process without even noticing.

32 33 34
So, when you upgrade GitLab Runner, the installation script kills and restarts
the runner process that was probably handling new jobs at
the time.
35 36 37

### Overriding systemd

38
For runners that use systemd, create
39 40 41
`/etc/systemd/system/gitlab-runner.service.d/kill.conf` with the following
content:

42
```toml
43 44 45 46 47 48
[Service]
TimeoutStopSec=7200
KillSignal=SIGQUIT
```

After adding these two settings to the systemd unit configuration, you can
49
stop the runner and systemd uses `SIGQUIT` as the kill signal, to stop the
50 51
process. Additionally, a 2h timeout is set for the stop command, which
means that if any jobs don't terminate gracefully before this timeout, systemd
52
kills the process by using `SIGKILL`.
53 54 55

### Overriding upstart

56
For runners that use upstart create `/etc/init/gitlab-runner.override` with the
57 58
following content:

59
```shell
60 61 62 63 64
kill signal SIGQUIT
kill timeout 7200
```

After adding these two settings to the upstart unit configuration, you can
65
stop the runner and upstart does exactly the same as systemd above.