Skip to content

Commit 5131bd3

Browse files
committed
Merge pull request #36 from elvanja/centos-specific-scripts-by-elvanja
Updated for v4.0
2 parents 76b94e9 + 1528537 commit 5131bd3

File tree

1 file changed

+69
-50
lines changed

1 file changed

+69
-50
lines changed

init.d/gitlab-centos

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22
#
33
# GitLab
4-
# Maintainer: @elvanja
5-
# App Version: 2.8.2
4+
# Maintainer: @elvanja, @troyanov
5+
# App Version: 4.0
66

77
# chkconfig: 2345 82 55
88
# processname: unicorn
@@ -36,62 +36,81 @@ OPTS="-c $APP_PATH/config/unicorn.rb -E production -D"
3636
RUBY_PATH_PATCH="PATH=$PATH:/usr/local/bin:/usr/local/lib && export PATH && "
3737

3838
start() {
39-
cd $APP_PATH
40-
41-
# Start unicorn
42-
echo -n $"Starting unicorn: "
43-
daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH bundle exec unicorn_rails $OPTS"
44-
[ $? -eq 0 ] && touch $ULOCK
45-
echo
46-
47-
# Start resque
48-
echo -n $"Starting resque: "
49-
daemon --pidfile=$RPID --user=$USER "$RUBY_PATH_PATCH ./resque.sh"
50-
[ $? -eq 0 ] && touch $RLOCK
51-
echo
39+
cd $APP_PATH
40+
41+
# Start unicorn
42+
echo -n $"Starting unicorn: "
43+
daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH bundle exec unicorn_rails $OPTS"
44+
unicorn=$?
45+
[ $unicorn -eq 0 ] && touch $ULOCK
46+
echo
47+
48+
# Start resque
49+
echo -n $"Starting resque: "
50+
daemon --pidfile=$RPID --user=$USER "$RUBY_PATH_PATCH ./resque.sh"
51+
resque=$?
52+
[ $resque -eq 0 ] && touch $RLOCK
53+
echo
54+
55+
retval=$unicorn || $resque
56+
return $retval
5257
}
5358

5459
stop() {
55-
cd $APP_PATH
56-
57-
# Stop unicorn
58-
echo -n $"Stopping unicorn: "
59-
killproc -p $UPID
60-
[ $? -eq 0 ] && rm -f $ULOCK
61-
echo
62-
63-
# Stop resque
64-
echo -n $"Stopping resque: "
65-
killproc -p $RPID
66-
[ $? -eq 0 ] && rm -f $RLOCK
67-
echo
60+
cd $APP_PATH
61+
62+
# Stop unicorn
63+
echo -n $"Stopping unicorn: "
64+
killproc -p $UPID
65+
unicorn=$?
66+
[ $unicorn -eq 0 ] && rm -f $ULOCK
67+
echo
68+
69+
# Stop resque
70+
echo -n $"Stopping resque: "
71+
killproc -p $RPID
72+
resque=$?
73+
[ $resque -eq 0 ] && rm -f $RLOCK
74+
echo
75+
76+
retval=$unicorn || $resque
77+
return $retval
6878
}
6979

70-
c_status() {
71-
status -p $UPID unicorn
72-
status -p $RPID resque
80+
restart() {
81+
stop
82+
start
83+
}
84+
85+
get_status() {
86+
status -p $UPID unicorn
87+
status -p $RPID resque
88+
}
89+
90+
query_status() {
91+
get_status >/dev/null 2>&1
7392
}
7493

7594
case "$1" in
76-
start)
77-
start
78-
;;
79-
stop)
80-
stop
81-
;;
82-
status)
83-
c_status
84-
;;
85-
restart)
86-
stop
87-
start
88-
;;
89-
*)
90-
N=/etc/init.d/$NAME
91-
echo "Usage: $N {start|stop|status|restart)" >&2
92-
exit 1
93-
;;
95+
start)
96+
query_status && exit 0
97+
start
98+
;;
99+
stop)
100+
query_status || exit 0
101+
stop
102+
;;
103+
restart)
104+
restart
105+
;;
106+
status)
107+
get_status
108+
;;
109+
*)
110+
N=/etc/init.d/$NAME
111+
echo "Usage: $N {start|stop|restart|status}" >&2
112+
exit 1
113+
;;
94114
esac
95115

96116
exit 0
97-

0 commit comments

Comments
 (0)