Repository navigation
Description
Describe the bug
A self-hosted runner that is installed as a service with svc.sh install on Linux can go offline and stay offline until someone starts it again by hand.
bin/RunnerService.jsstops for good when the listener exits with code 0, 1 or 5, or after 10 retryable exits (2, 3, 4) in a row.- It then exits with status 0, and
runsvc.shexits with it. src/Misc/layoutbin/actions.runner.service.templatehas noRestart=, so systemd leaves the unit inactive.
Nothing else restarts the runner. Jobs whose labels only such runners have stay "Waiting for a runner to pick up this job" until the 24-hour queue limit, and timeout-minutes does not count that wait.
We hit this on 2026-11-27. Two runners on one host went offline under memory pressure and did not come back, and a job that only they could take stayed queued for more than three hours.
To Reproduce
The script below runs RunnerService.js with a stub listener that exits with a given code. It needs node and a runner checkout; it takes about a minute.
#!/usr/bin/env bash
set -euo pipefail
src=${1:?path to src/Misc/layoutbin/RunnerService.js}
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT
mkdir -p "$work/bin"; cp "$src" "$work/bin/RunnerService.js"
for code in 0 1 5 2; do
printf '#!/bin/sh\necho start >> "%s/starts"\nexit %s\n' "$work" "$code" > "$work/bin/Runner.Listener"
chmod +x "$work/bin/Runner.Listener"; : > "$work/starts"
set +e; timeout 70 node "$work/bin/RunnerService.js" > "$work/out" 2>&1; status=$?; set -e
echo "listener exit $code: service host exit $status, $(wc -l < "$work/starts") listener start(s): $(tail -1 "$work/out")"
doneOutput at commit f467e9e:
listener exit 0: service host exit 0, 1 listener start(s): Runner listener exit with 0 return code, stop the service, no retry needed.
listener exit 1: service host exit 0, 1 listener start(s): Runner listener exit with terminated error, stop the service, no retry needed.
listener exit 5: service host exit 0, 1 listener start(s): Runner listener exit with Session Conflict error, stop the service, no retry needed.
listener exit 2: service host exit 0, 10 listener start(s): Stopping the runner after 10 consecutive re-tryable failures
With the unit from svc.sh install, systemctl is-active reports inactive after any of these, and the runner shows as offline on GitHub.
Expected behavior
A runner that runs as a service comes back without manual action after a stop that an operator did not ask for.
Workaround
Add a drop-in, for example /etc/systemd/system/actions.runner.<name>.service.d/restart.conf:
[Unit]
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=30sThen run systemctl daemon-reload. It must be Restart=always: because the service host exits with status 0, Restart=on-failure does not restart it. systemctl stop and systemctl restart still work as before.
Suggested fix
- Merge Set Restart=always on systemd service for added resilience #4068, which adds
Restart=alwaysandRestartSecto the template. AddingStartLimitIntervalSec=0also avoids hitting systemd's start limit when a runner keeps failing. - Optionally, exit
RunnerService.jswith a non-zero status when it stops after repeated failures, so thatsystemctl statusshowsfailedrather than a clean stop.
Related: #4068, #4648 (the same "exits permanently, systemd service then remains inactive" after clock skew), #3909 (KillMode=process with restarts).
Runner Version and Platform
2.338.2, Linux x64 (Ubuntu 24.04), installed as a systemd service.
Activity