Skip to content

Instantly share code, notes, and snippets.

@kotashiratsuka
Created December 24, 2013 18:18
Show Gist options
  • Save kotashiratsuka/8116477 to your computer and use it in GitHub Desktop.
Save kotashiratsuka/8116477 to your computer and use it in GitHub Desktop.
RHEL Based Simple GitLab CI Runner initscript.
#!/bin/sh
### BEGIN INIT INFO
# Provides: gitlab-ci-runner
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab CI Runner init.d script
# Description: Enables automatic start of runners at boot time in the background.
### END INIT INFO
# https://gist.github.com/kotashiratsuka/8116477
# source function library
. /etc/rc.d/init.d/functions
APP_ROOT="/home/gitlab_ci_runner/gitlab-ci-runner"
APP_USER="gitlab_ci_runner"
PID_PATH="$APP_ROOT/tmp/pids"
RUNNER_PID="$PID_PATH/runners.pid"
RETVAL=0
start() {
cd $APP_ROOT
echo -n $"Starting Gitlab CI Runner: "
daemon --pidfile=${RUNNER_PID} --user=${APP_USER} "bundle exec bin/runner >/dev/null 2>&1 & echo \$! >> ${RUNNER_PID}"
RETIVAL=$?
echo
}
stop() {
cd $APP_ROOT
echo -n $"Stopping Gitlab CI Runner: "
killproc -p ${RUNNER_PID}
RETIVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status -p ${RUNNER_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