]> git.pld-linux.org Git - packages/gitlab-ce.git/blame - gitlab-unicorn.init
- unconditional noarch subpackages
[packages/gitlab-ce.git] / gitlab-unicorn.init
CommitLineData
7db376f0
ER
1#!/bin/sh
2#
3# gitlab-unicorn gitlab-unicorn short service description
4#
5# chkconfig: 345 82 18
6# description: Runs unicorn
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.
20if is_yes "${NETWORKING}"; then
21 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
22 msg_network_down "GitLab Unicorn"
23 exit 1
24 fi
25else
26 exit 0
27fi
28
29### Environment variables
30RAILS_ENV="production"
31
32# The username and path to the gitlab source
33USER=git
34df8417 34APP_PATH=/usr/lib/gitlab
7db376f0
ER
35
36# The PID and LOCK files used by unicorn and sidekiq
bab42173 37pidfile=$APP_PATH/tmp/pids/unicorn.pid
7db376f0
ER
38lockfile=/var/lock/subsys/gitlab-unicorn
39
40# Get service config - may override defaults
41[ -f /etc/sysconfig/gitlab-unicorn ] && . /etc/sysconfig/gitlab-unicorn
42
43start() {
44 # Check if the service is already running?
45 if [ -f $lockfile ]; then
46 msg_already_running "GitLab Unicorn"
47 return
48 fi
49
50 msg_starting "GitLab Unicorn"
13dc24ec 51 RC_LOGGING=no
7db376f0 52 daemon --pidfile $pidfile --user $USER --chdir "$APP_PATH" \
13dc24ec
ER
53 /usr/bin/env RAILS_ENV=$RAILS_ENV \
54 bin/web start
7db376f0
ER
55 RETVAL=$?
56 [ $RETVAL -eq 0 ] && touch $lockfile
57}
58
59stop() {
60 if [ ! -f $lockfile ]; then
61 msg_not_running "GitLab Unicorn"
62 return
63 fi
64
65 # Stop daemons.
66 msg_stopping "GitLab Unicorn"
67 killproc --pidfile $pidfile unicorn
68 rm -f $lockfile
69}
70
7db376f0
ER
71condrestart() {
72 if [ ! -f $lockfile ]; then
73 msg_not_running "GitLab Unicorn"
74 RETVAL=$1
75 return
76 fi
77
78 stop
79 start
80}
81
82RETVAL=0
83# See how we were called.
84case "$1" in
85 start)
86 start
87 ;;
88 stop)
89 stop
90 ;;
91 restart)
92 stop
93 start
94 ;;
95 try-restart)
96 condrestart 0
97 ;;
98 force-reload)
99 condrestart 7
100 ;;
101 status)
9003de5f 102 status --pidfile $pidfile unicorn_rails
7db376f0
ER
103 RETVAL=$?
104 ;;
105 *)
106 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
107 exit 3
108esac
109
110exit $RETVAL
This page took 0.09616 seconds and 5 git commands to generate.