]> git.pld-linux.org Git - packages/gitlab-workhorse.git/blob - gitlab-workhorse.init
438e253f0277b80e9ae72e31835bdcad85eabd7a
[packages/gitlab-workhorse.git] / gitlab-workhorse.init
1 #!/bin/sh
2 #
3 # gitlab-workhorse GitLab Workhorse
4 #
5 # chkconfig:    345 82 18
6 # description: Runs GitLab Workhorse
7 # processname: gitlab-workhorse
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Get network config
13 . /etc/sysconfig/network
14
15 # Check that networking is up.
16 if is_yes "${NETWORKING}"; then
17         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18                 msg_network_down "GitLab Workhorse"
19                 exit 1
20         fi
21 else
22         exit 0
23 fi
24
25 ### Environment variables
26 RAILS_ENV="production"
27
28 # The username and path to the gitlab source
29 USER=git
30 APP_PATH=/usr/lib/gitlab
31
32 # The PID and LOCK files
33 pidfile=/var/run/gitlab/gitlab-workhorse.pid
34 lockfile=/var/lock/subsys/gitlab-workhorse
35
36 # Get service config - may override defaults
37 [ -f /etc/sysconfig/gitlab-workhorse ] && . /etc/sysconfig/gitlab-workhorse
38
39 start() {
40         # Check if the service is already running?
41         if [ -f $lockfile ]; then
42                 msg_already_running "GitLab Workhorse"
43                 return
44         fi
45
46         msg_starting "GitLab Workhorse"
47         # initlog would cause fd1 and fd2 to be pipe
48         # those won't exist when workhorse tries to write to stdout causing it to abort with SIGPIPE
49         # http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2016-September/025111.html
50         RC_LOGGING=no
51         daemon --pidfile $pidfile --user $USER --makepid --chdir "$APP_PATH" --redirfds --fork \
52                 /usr/sbin/gitlab-workhorse -listenUmask 0 \
53                         -authBackend http://localhost:8080 -authSocket /var/run/gitlab/gitlab.socket \
54                         -documentRoot /usr/lib/gitlab/public \
55                         -listenNetwork unix -listenAddr /var/run/gitlab/gitlab-workhorse.socket
56         RETVAL=$?
57         [ $RETVAL -eq 0 ] && touch $lockfile
58 }
59
60 stop() {
61         if [ ! -f $lockfile ]; then
62                 msg_not_running "GitLab Workhorse"
63                 return
64         fi
65
66         # Stop daemons.
67         msg_stopping "GitLab Workhorse"
68         killproc --pidfile $pidfile gitlab-workhorse
69         RETVAL=$?
70         rm -f $lockfile
71 }
72
73 condrestart() {
74         if [ ! -f $lockfile ]; then
75                 msg_not_running "GitLab Workhorse"
76                 RETVAL=$1
77                 return
78         fi
79
80         stop
81         start
82 }
83
84 RETVAL=0
85 # See how we were called.
86 case "$1" in
87   start)
88         start
89         ;;
90   stop)
91         stop
92         ;;
93   restart)
94         stop
95         start
96         ;;
97   try-restart)
98         condrestart 0
99         ;;
100   force-reload)
101         condrestart 7
102         ;;
103   status)
104         status --pidfile $pidfile gitlab-workhorse
105         RETVAL=$?
106         ;;
107   *)
108         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
109         exit 3
110 esac
111
112 exit $RETVAL
This page took 0.055163 seconds and 2 git commands to generate.