summaryrefslogtreecommitdiff
path: root/user/gitlab-runner/gitlab-runner.initd
diff options
context:
space:
mode:
Diffstat (limited to 'user/gitlab-runner/gitlab-runner.initd')
-rw-r--r--user/gitlab-runner/gitlab-runner.initd45
1 files changed, 45 insertions, 0 deletions
diff --git a/user/gitlab-runner/gitlab-runner.initd b/user/gitlab-runner/gitlab-runner.initd
new file mode 100644
index 000000000..1fc47410c
--- /dev/null
+++ b/user/gitlab-runner/gitlab-runner.initd
@@ -0,0 +1,45 @@
+#!/sbin/openrc-run
+
+: "${CONFIG_FILE:=/etc/gitlab-runner/config.toml}"
+: "${logfile:=/var/log/gitlab-runner.log}"
+: "${timeout:=300}"
+: "${retry:=60}"
+: "${command_user:=gitlab-runner:gitlab-runner}"
+export CONFIG_FILE
+
+command="/usr/bin/gitlab-runner"
+command_args="run --service ${RC_SVCNAME} ${command_args}"
+command_background="true"
+start_stop_daemon_args="--stdout ${logfile} --stderr ${logfile}"
+pidfile="/run/${RC_SVCNAME}.pid"
+
+extra_started_commands="reload gracefulstop"
+description_reload="Reload configuration"
+description_gracefulstop="Finish current jobs, then stop"
+
+start_pre() {
+ checkpath -f -m 640 -o "${command_user}" "${logfile}"
+}
+
+reload() {
+ ebegin "Reloading ${RC_SVCNAME} configuration"
+ start-stop-daemon --quiet --signal HUP --pidfile "${pidfile}"
+ eend $?
+}
+
+gracefulstop() {
+ ebegin "Gracefully stopping ${RC_SVCNAME}"
+ mark_service_stopping "${RC_SERVICE}"
+ start-stop-daemon --quiet --progress --stop --pidfile "${pidfile}" \
+ --signal QUIT --retry "${timeout}"
+ if eend $?; then
+ mark_service_stopped "${RC_SVCNAME}"
+ else
+ eerror "${RC_SVCNAME} timed out, forcefully stopping"
+ if stop; then
+ mark_service_stopped "${RC_SVCNAME}"
+ else
+ return 1
+ fi
+ fi
+}