Skip to content

Instantly share code, notes, and snippets.

@mvrilo
Created October 23, 2012 17:36
Show Gist options
  • Save mvrilo/3940255 to your computer and use it in GitHub Desktop.
Save mvrilo/3940255 to your computer and use it in GitHub Desktop.
gitlab init
#! /bin/bash
# GITLAB
# Maintainer: @randx
# App Version: 2.9
# from: https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
APP_ROOT="/home/gitlab/gitlab"
DAEMON_OPTS="-C $APP_ROOT/config/thin.yml"
NAME="gitlab"
DESC="Gitlab service"
PID="$APP_ROOT/tmp/pids/thin.pid"
RESQUE_PID="$APP_ROOT/tmp/pids/resque_worker.pid"
case "$1" in
start)
CD_TO_APP_DIR="cd $APP_ROOT"
START_DAEMON_PROCESS="bundle exec thin start $DAEMON_OPTS"
START_RESQUE_PROCESS="./resque.sh"
echo -n "Starting $DESC: "
if [ `whoami` = root ]; then
sudo -u gitlab -H sh -l -c "$CD_TO_APP_DIR && $START_DAEMON_PROCESS #&& $START_RESQUE_PROCESS"
else
$CD_TO_APP_DIR && $START_DAEMON_PROCESS #&& $START_RESQUE_PROCESS
fi
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $PID`
#kill -QUIT `cat $RESQUE_PID`
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill -USR2 `cat $PID`
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
kill -HUP `cat $PID`
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment