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