Skip to content

Instantly share code, notes, and snippets.

@eduardodeoh
Created November 1, 2012 00:58
Show Gist options
  • Save eduardodeoh/3990964 to your computer and use it in GitHub Desktop.
Save eduardodeoh/3990964 to your computer and use it in GitHub Desktop.
Gitlab Resque Init Script for Ubuntu 12.04
#! /bin/bash
# GITLAB
# Maintainer: @randx
# App Version: 3.0
# Modified by @eduardodeoh (Start GITLAB Resque only)
### 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"
NAME="gitlab-resque"
DESC="Gitlab Resque service"
RESQUE_PID="$APP_ROOT/tmp/pids/resque_worker.pid"
GITLAB_USER="gitlab"
case "$1" in
start)
CD_TO_APP_DIR="cd $APP_ROOT"
START_RESQUE_PROCESS="./resque.sh"
echo -n "Starting $DESC: "
if [ `whoami` = root ]; then
sudo -u $GITLAB_USER -H sh -l -c "$CD_TO_APP_DIR && $START_RESQUE_PROCESS"
else
$CD_TO_APP_DIR && $START_RESQUE_PROCESS
fi
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill -QUIT `cat $RESQUE_PID`
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment