Skip to content

Instantly share code, notes, and snippets.

@ngyuki
Created September 24, 2012 05:29
Show Gist options
  • Save ngyuki/3774412 to your computer and use it in GitHub Desktop.
Save ngyuki/3774412 to your computer and use it in GitHub Desktop.
GitLab の CentOS 用の init スクリプト
#!/bin/bash
#
# GitLab
# Maintainer: @elvanja
# App Version: 2.8.2
# chkconfig: 2345 82 55
# processname: unicorn
# processname: rescue
# description: Runs unicorn and resque for nginx integration.
# Related (kudos @4sak3n0ne):
# https://github.com/gitlabhq/gitlabhq/issues/1049#issuecomment-8386882
# https://gist.github.com/3062860
# Include RedHat function library
. /etc/rc.d/init.d/functions
# The name of the service
NAME=gitlab
# The username and path to the gitlab source
USER=$NAME
APP_PATH=/var/lib/gitlab/gitlabhq
# The PID and LOCK files used by unicorn and resque
RPID=$APP_PATH/tmp/pids/resque_worker.pid
RLOCK=/var/lock/subsys/resque
# Ruby related path update
RUBY_PATH_PATCH="PATH=$PATH:/usr/local/bin:/usr/local/lib && export PATH && "
start() {
cd $APP_PATH
# Start resque
echo -n $"Starting resque: "
daemon --pidfile=$RPID --user=$USER "$RUBY_PATH_PATCH ./resque.sh"
[ $? -eq 0 ] && touch $RLOCK
echo
}
stop() {
cd $APP_PATH
# Stop resque
echo -n $"Stopping resque: "
killproc -p $RPID
[ $? -eq 0 ] && rm -f $RLOCK
echo
}
c_status() {
status -p $RPID resque
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
c_status
;;
restart)
stop
start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|status|restart)" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment