]> git.pld-linux.org Git - packages/gitlab-runner.git/blame - gitlab-runner.init
start-stop-daemon --background discards output; use shell backgrounding
[packages/gitlab-runner.git] / gitlab-runner.init
CommitLineData
50a69960
ER
1#!/bin/sh
2#
8264fff3 3# gitlab-runner GitLab Runner
50a69960
ER
4#
5# chkconfig: 345 20 80
6# description: Enables automatic start of runners at boot time in the background
8264fff3 7# processname: gitlab-runner
af21cb3e 8
50a69960
ER
9# Source function library
10. /etc/rc.d/init.d/functions
af21cb3e 11
8264fff3 12DESC="GitLab Runner"
50a69960
ER
13USER="gitlab-runner"
14GROUP="gitlab-runner"
15CHDIR="/var/lib/gitlab-runner"
8264fff3 16NAME="gitlab-runner"
ea381f69 17DAEMON="/usr/bin/gitlab-runner"
8264fff3
ER
18PIDFILE="/var/run/gitlab-runner.pid"
19LOGFILE="/var/log/gitlab-runner.log"
af21cb3e 20
af21cb3e 21# Read configuration variable file if it is present
50a69960 22[ -f /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
af21cb3e 23
50a69960
ER
24do_start() {
25 start-stop-daemon --start \
26 --pidfile "$PIDFILE" \
27 --chdir "$CHDIR" \
50a69960
ER
28 --make-pidfile \
29 --chuid "$USER:$GROUP" \
6f5a8286 30 --exec "$DAEMON" -- "run" >> $LOGFILE 2>&1 &
50a69960 31}
af21cb3e 32
50a69960
ER
33do_stop() {
34 start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet
35}
af21cb3e 36
89c5c179
ER
37okfail() {
38 if [ "$1" = 0 ]; then
39 ok
40 else
41 fail
42 fi
43}
44
50a69960
ER
45start() {
46 # Check if the service is already running?
47 if [ -f /var/lock/subsys/$NAME ]; then
48 msg_already_running "$DESC"
49 return
50 fi
af21cb3e 51
50a69960
ER
52 msg_starting "$DESC"
53 do_start
54 RETVAL=$?
89c5c179 55 okfail $RETVAL
50a69960 56 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
af21cb3e
ER
57}
58
50a69960
ER
59stop() {
60 if [ ! -f /var/lock/subsys/$NAME ]; then
61 msg_not_running "$DESC"
62 return
63 fi
64
65 # Stop daemons.
66 msg_stopping "$DESC"
67 do_stop
89c5c179 68 okfail $?
50a69960
ER
69 rm -f /var/lock/subsys/$NAME
70}
71
72condrestart() {
73 if [ ! -f /var/lock/subsys/$NAME ]; then
74 msg_not_running "$DESC"
75 RETVAL=$1
76 return
77 fi
78
79 stop
80 start
af21cb3e
ER
81}
82
7b2edca7
ER
83# run gitlab-runner register with proper uid/gid
84register() {
85 runuser -u "$USER" -g "$GROUP" gitlab-runner "$@"
86}
87
50a69960
ER
88RETVAL=0
89# See how we were called.
af21cb3e
ER
90case "$1" in
91 start)
50a69960
ER
92 start
93 ;;
af21cb3e 94 stop)
50a69960
ER
95 stop
96 ;;
af21cb3e 97 restart)
50a69960
ER
98 stop
99 start
100 ;;
101 try-restart)
102 condrestart 0
103 ;;
104 force-reload)
105 condrestart 7
106 ;;
7b2edca7
ER
107 register)
108 register "$@"
109 ;;
af21cb3e 110 status)
4bd75c48 111 status --pidfile $PIDFILE $NAME
50a69960
ER
112 RETVAL=$?
113 ;;
af21cb3e 114 *)
7b2edca7 115 msg_usage "$0 {start|stop|restart|try-restart|force-reload|register|status}"
50a69960 116 exit 3
af21cb3e
ER
117esac
118
50a69960 119exit $RETVAL
This page took 0.079314 seconds and 4 git commands to generate.