mirror of
https://github.com/jlengrand/gitlab-recipes.git
synced 2026-03-10 08:11:17 +00:00
Add sysvinit configs for puma and unicorn
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# GitLab
|
||||
# Contributors : @elvanja, @troyanov, @eiyaya, @foyo23, @nielsbasjes, @relip, @JasonMing, @andronat
|
||||
# App Version : 5.x
|
||||
# App Version : 6.x
|
||||
|
||||
# chkconfig: 2345 82 55
|
||||
# processname: puma
|
||||
126
init/sysvinit/centos/gitlab-unicorn
Normal file
126
init/sysvinit/centos/gitlab-unicorn
Normal file
@@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# GitLab
|
||||
# Contributors : @elvanja, @troyanov, @eiyaya, @foyo23, @nielsbasjes, @relip, @JasonMing, @andronat
|
||||
# App Version : 6.x
|
||||
|
||||
# chkconfig: 2345 82 55
|
||||
# processname: unicorn
|
||||
# processname: sidekiq
|
||||
# description: Runs unicorn and sidekiq for nginx integration.
|
||||
|
||||
# Related (kudos @4sak3n0ne):
|
||||
# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
|
||||
# https://gist.github.com/3062860
|
||||
|
||||
# Save original $PATH
|
||||
# /etc/rc.d/init.d/functions resets $PATH to default(/sbin:/usr/sbin:/bin:/usr/bin).
|
||||
# Consequently, rvm and compiled ruby with custom path (which isn't /usr/bin) cannot be executed.
|
||||
ORIGINAL_PATH=$PATH
|
||||
|
||||
# Include RedHat function library
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# Restore original $PATH
|
||||
PATH=$ORIGINAL_PATH
|
||||
|
||||
# The name of the service
|
||||
NAME=git
|
||||
|
||||
# The username and path to the gitlab source
|
||||
USER=git
|
||||
APP_PATH=/home/$USER/gitlab
|
||||
|
||||
# The PID and LOCK files used by unicorn and sidekiq
|
||||
UPID=$APP_PATH/tmp/pids/unicorn.pid
|
||||
ULOCK=/var/lock/subsys/unicorn
|
||||
SPID=$APP_PATH/tmp/pids/sidekiq.pid
|
||||
SLOCK=/var/lock/subsys/sidekiq
|
||||
|
||||
# The options to use when running unicorn
|
||||
OPTS="-c $APP_PATH/config/unicorn.rb -D -E production"
|
||||
|
||||
# Ruby related path update
|
||||
RVM_PATH="/usr/local/rvm/bin"
|
||||
RUBY_PATH_PATCH="PATH=/usr/local/bin:/usr/local/lib:/home/git/bin:$RVM_PATH:$PATH && export PATH && "
|
||||
|
||||
start() {
|
||||
cd $APP_PATH
|
||||
|
||||
# Start unicorn
|
||||
echo -n $"Starting unicorn: "
|
||||
daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production bundle exec unicorn_rails $OPTS"
|
||||
unicorn=$?
|
||||
[ $unicorn -eq 0 ] && touch $ULOCK
|
||||
echo
|
||||
|
||||
# Start sidekiq
|
||||
echo -n $"Starting sidekiq: "
|
||||
daemon --pidfile=$SPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production bundle exec rake sidekiq:start"
|
||||
sidekiq=$?
|
||||
[ $sidekiq -eq 0 ] && touch $SLOCK
|
||||
echo
|
||||
|
||||
retval=$unicorn || $sidekiq
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
cd $APP_PATH
|
||||
|
||||
# Stop unicorn
|
||||
echo -n $"Stopping unicorn: "
|
||||
killproc -p $UPID
|
||||
unicorn=$?
|
||||
[ $unicorn -eq 0 ] && rm -f $ULOCK
|
||||
echo
|
||||
|
||||
# Stop sidekiq
|
||||
echo -n $"Stopping sidekiq: "
|
||||
killproc -p $SPID
|
||||
sidekiq=$?
|
||||
[ $sidekiq -eq 0 ] && rm -f $SLOCK
|
||||
echo
|
||||
|
||||
retval=$unicorn || $sidekiq
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
get_status() {
|
||||
status -p $UPID unicorn
|
||||
status -p $SPID sidekiq
|
||||
}
|
||||
|
||||
query_status() {
|
||||
get_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
query_status && exit 0
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
query_status || exit 0
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
get_status
|
||||
;;
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user