Skip to content

Instantly share code, notes, and snippets.

@kotashiratsuka
Created December 24, 2013 18:14
Show Gist options
  • Save kotashiratsuka/8116440 to your computer and use it in GitHub Desktop.
Save kotashiratsuka/8116440 to your computer and use it in GitHub Desktop.
RHEL Based Simple GitLab CI Initscript.
#!/bin/bash
# GITLAB CI
# Author: @kotashiratsuka
# App Version: 4.1.0
### BEGIN INIT INFO
# Provides: gitlab-ci
# 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 CI
# Description: GitLab CI
### END INIT INFO
# https://gist.github.com/kotashiratsuka/8116440
# source function library
. /etc/rc.d/init.d/functions
APP_USER="gitlab_ci"
APP_ROOT="/home/$APP_USER/gitlab-ci"
SOCKET_PATH="$APP_ROOT/tmp/sockets"
PID_PATH="$APP_ROOT/tmp/pids"
SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
RETVAL=0
start() {
cd $APP_ROOT
echo -n $"Starting Gitlab CI: "
daemon --pidfile=$SIDEKIQ_PID --user=$APP_USER "mkdir -p $PID_PATH && $START_SIDEKIQ"
RETVAL=$?
echo
}
stop() {
cd $APP_ROOT
echo -n $"Stopping Gitlab CI: "
killproc -p ${SIDEKIQ_PID}
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status -p ${SIDEKIQ_PID}
;;
*)
echo "Usage: $0 {start|stop|restart|status}" >&2
RETVAL=1
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment