]> git.pld-linux.org Git - packages/gitlab-ce.git/blob - gitlab-sidekiq.init
schama.rb needs to be writable
[packages/gitlab-ce.git] / gitlab-sidekiq.init
1 #!/bin/sh
2 #
3 # gitlab-sidekiq GitLab Sidekiq Worker
4 #
5 # chkconfig:    345 82 18
6 # description: Runs GitLab Sidekiq Worker
7 # processname: sidekiq
8
9 # Related (kudos @4sak3n0ne):
10 # https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
11 # https://gist.github.com/3062860
12
13 # Source function library
14 . /etc/rc.d/init.d/functions
15
16 # Get network config
17 . /etc/sysconfig/network
18
19 # Check that networking is up.
20 if is_yes "${NETWORKING}"; then
21         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
22                 msg_network_down "GitLab Sidekiq"
23                 exit 1
24         fi
25 else
26         exit 0
27 fi
28
29 ### Environment variables
30 RAILS_ENV="production"
31
32 # The username and path to the gitlab source
33 USER=git
34 APP_PATH=/var/lib/gitlab
35
36 # The PID and LOCK files used by unicorn and sidekiq
37 pidfile=$APP_PATH/tmp/pids/sidekiq.pid
38 lockfile=/var/lock/subsys/gitlab-sidekiq
39
40 # Get service config - may override defaults
41 [ -f /etc/sysconfig/gitlab-sidekiq ] && . /etc/sysconfig/gitlab-sidekiq
42
43 start() {
44         # Check if the service is already running?
45         if [ -f $lockfile ]; then
46                 msg_already_running "GitLab Sidekiq"
47                 return
48         fi
49
50         msg_starting "GitLab Sidekiq"
51         daemon --pidfile $pidfile --user $USER --chdir "$APP_PATH" \
52                 env RAILS_ENV=$RAILS_ENV \
53                 bin/background_jobs start
54         RETVAL=$?
55         [ $RETVAL -eq 0 ] && touch $lockfile
56 }
57
58 stop() {
59         if [ ! -f $lockfile ]; then
60                 msg_not_running "GitLab Sidekiq"
61                 return
62         fi
63
64         # Stop daemons.
65         msg_stopping "GitLab Sidekiq"
66         daemon --pidfile $pidfile --user $USER --chdir "$APP_PATH" \
67                 env RAILS_ENV=$RAILS_ENV \
68                 bin/background_jobs stop
69         RETVAL=$?
70         rm -f $lockfile
71 }
72
73 condrestart() {
74         if [ ! -f $lockfile ]; then
75                 msg_not_running "GitLab Sidekiq"
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 sidekiq
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.040334 seconds and 3 git commands to generate.