Skip to content

Commit d874d1c

Browse files
committed
Add sysvinit configs for puma and unicorn
1 parent 8856901 commit d874d1c

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

init/sysvinit/centos/gitlab-centos renamed to init/sysvinit/centos/gitlab-puma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# GitLab
44
# Contributors : @elvanja, @troyanov, @eiyaya, @foyo23, @nielsbasjes, @relip, @JasonMing, @andronat
5-
# App Version : 5.x
5+
# App Version : 6.x
66

77
# chkconfig: 2345 82 55
88
# processname: puma

init/sysvinit/centos/gitlab-unicorn

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
#
3+
# GitLab
4+
# Contributors : @elvanja, @troyanov, @eiyaya, @foyo23, @nielsbasjes, @relip, @JasonMing, @andronat
5+
# App Version : 6.x
6+
7+
# chkconfig: 2345 82 55
8+
# processname: unicorn
9+
# processname: sidekiq
10+
# description: Runs unicorn and sidekiq for nginx integration.
11+
12+
# Related (kudos @4sak3n0ne):
13+
# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
14+
# https://gist.github.com/3062860
15+
16+
# Save original $PATH
17+
# /etc/rc.d/init.d/functions resets $PATH to default(/sbin:/usr/sbin:/bin:/usr/bin).
18+
# Consequently, rvm and compiled ruby with custom path (which isn't /usr/bin) cannot be executed.
19+
ORIGINAL_PATH=$PATH
20+
21+
# Include RedHat function library
22+
. /etc/rc.d/init.d/functions
23+
24+
# Restore original $PATH
25+
PATH=$ORIGINAL_PATH
26+
27+
# The name of the service
28+
NAME=git
29+
30+
# The username and path to the gitlab source
31+
USER=git
32+
APP_PATH=/home/$USER/gitlab
33+
34+
# The PID and LOCK files used by unicorn and sidekiq
35+
UPID=$APP_PATH/tmp/pids/unicorn.pid
36+
ULOCK=/var/lock/subsys/unicorn
37+
SPID=$APP_PATH/tmp/pids/sidekiq.pid
38+
SLOCK=/var/lock/subsys/sidekiq
39+
40+
# The options to use when running unicorn
41+
OPTS="-c $APP_PATH/config/unicorn.rb -D -E production"
42+
43+
# Ruby related path update
44+
RVM_PATH="/usr/local/rvm/bin"
45+
RUBY_PATH_PATCH="PATH=/usr/local/bin:/usr/local/lib:/home/git/bin:$RVM_PATH:$PATH && export PATH && "
46+
47+
start() {
48+
cd $APP_PATH
49+
50+
# Start unicorn
51+
echo -n $"Starting unicorn: "
52+
daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production bundle exec unicorn_rails $OPTS"
53+
unicorn=$?
54+
[ $unicorn -eq 0 ] && touch $ULOCK
55+
echo
56+
57+
# Start sidekiq
58+
echo -n $"Starting sidekiq: "
59+
daemon --pidfile=$SPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production bundle exec rake sidekiq:start"
60+
sidekiq=$?
61+
[ $sidekiq -eq 0 ] && touch $SLOCK
62+
echo
63+
64+
retval=$unicorn || $sidekiq
65+
return $retval
66+
}
67+
68+
stop() {
69+
cd $APP_PATH
70+
71+
# Stop unicorn
72+
echo -n $"Stopping unicorn: "
73+
killproc -p $UPID
74+
unicorn=$?
75+
[ $unicorn -eq 0 ] && rm -f $ULOCK
76+
echo
77+
78+
# Stop sidekiq
79+
echo -n $"Stopping sidekiq: "
80+
killproc -p $SPID
81+
sidekiq=$?
82+
[ $sidekiq -eq 0 ] && rm -f $SLOCK
83+
echo
84+
85+
retval=$unicorn || $sidekiq
86+
return $retval
87+
}
88+
89+
restart() {
90+
stop
91+
start
92+
}
93+
94+
get_status() {
95+
status -p $UPID unicorn
96+
status -p $SPID sidekiq
97+
}
98+
99+
query_status() {
100+
get_status >/dev/null 2>&1
101+
}
102+
103+
case "$1" in
104+
start)
105+
query_status && exit 0
106+
start
107+
;;
108+
stop)
109+
query_status || exit 0
110+
stop
111+
;;
112+
restart)
113+
restart
114+
;;
115+
status)
116+
get_status
117+
;;
118+
*)
119+
N=/etc/init.d/$NAME
120+
echo "Usage: $N {start|stop|restart|status}" >&2
121+
exit 1
122+
;;
123+
esac
124+
125+
exit 0
126+

0 commit comments

Comments
 (0)