Skip to content

Commit 720ecad

Browse files
committed
Merge pull request #169 from Estopero/master
Adding a init.d script without unicorn or puma, just sidekiq
2 parents 21c42fd + ba0ab28 commit 720ecad

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
#
3+
# GitLab
4+
# Contributors : @elvanja, @troyanov, @eiyaya, @foyo23, @nielsbasjes, @relip, @JasonMing, @andronat, @axilleas
5+
# App Version : 6.x
6+
7+
# chkconfig: 2345 82 55
8+
# processname: sidekiq
9+
# description: Runs sidekiq for nginx integration.
10+
11+
# Related (kudos @4sak3n0ne):
12+
# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
13+
# https://gist.github.com/3062860
14+
15+
# Include RedHat function library
16+
. /etc/rc.d/init.d/functions
17+
18+
# The name of the service
19+
NAME=${0##*/}
20+
21+
### Environment variables
22+
RAILS_ENV="production"
23+
24+
# The username and path to the gitlab source
25+
USER=git
26+
APP_PATH=/home/git/gitlab
27+
28+
# The PID and LOCK files used by unicorn and sidekiq
29+
SPID=$APP_PATH/tmp/pids/sidekiq.pid
30+
SLOCK=/var/lock/subsys/sidekiq
31+
32+
# Evaluate the real path for the user (should already have RVM)
33+
PATH_PATCH="PATH=$(su $USER -l -c "echo \"\$PATH\"") && export PATH && "
34+
35+
start() {
36+
cd $APP_PATH
37+
38+
# Start sidekiq
39+
echo -n $"Starting sidekiq: "
40+
daemon --pidfile=$SPID --user=$USER "$PATH_PATCH RAILS_ENV=$RAILS_ENV script/background_jobs start"
41+
sidekiq=$?
42+
[ $sidekiq -eq 0 ] && touch $SLOCK
43+
echo
44+
45+
retval=$sidekiq
46+
return $retval
47+
}
48+
49+
stop() {
50+
cd $APP_PATH
51+
52+
# Stop sidekiq
53+
echo -n $"Stopping sidekiq: "
54+
killproc -p $SPID
55+
sidekiq=$?
56+
[ $sidekiq -eq 0 ] && rm -f $SLOCK
57+
echo
58+
59+
retval=$sidekiq
60+
return $retval
61+
}
62+
63+
restart() {
64+
stop
65+
start
66+
}
67+
68+
get_status() {
69+
status -p $SPID sidekiq
70+
sidekiq=$?
71+
72+
retval=$sidekiq
73+
return $retval
74+
}
75+
76+
query_status() {
77+
get_status >/dev/null 2>&1
78+
return $?
79+
}
80+
81+
case "$1" in
82+
start)
83+
query_status && exit 0
84+
start
85+
;;
86+
stop)
87+
query_status || exit 0
88+
stop
89+
;;
90+
restart)
91+
restart
92+
;;
93+
status)
94+
get_status
95+
exit $?
96+
;;
97+
*)
98+
N=/etc/init.d/$NAME
99+
echo "Usage: $N {start|stop|restart|status}" >&2
100+
exit 1
101+
;;
102+
esac
103+
104+
exit 0
105+

0 commit comments

Comments
 (0)