fixed some problems with the init script and cleanes up oldfiles

This commit is contained in:
Manuel Friedli 2014-09-24 18:44:49 +02:00
parent 5ade9026b9
commit 7365a9e8ab
4 changed files with 5 additions and 148 deletions

View file

@ -1,5 +1,4 @@
AUX gitlab-ci-runner-5.0.0-fix-gemfile.patch 1099 SHA256 80dddabf6c0abf0096a9ba54fe5d4f7408f47c624429ff5ac2bc19afe99b5461 SHA512 208db66cb21e467656a798f8954c474a614d3de406601806e906edbafbacafef7670f2913eae43d897be38bef1f26c70cf2a33901d0667dff4f1b1b89643f08d WHIRLPOOL 5b6e4eabc1d3a7e3320cf4616d9890c221ff306aa246aaefe8b87c9e6a631ebe7c658435225f7e546d34ce21ada063a016dad5080208765879211d2a1df7a26a
AUX gitlab-ci-runner-ORIGINAL.init 3604 SHA256 059b579cfa740ead757f0e8befd7de5b13ecbae94264a70710d23a2b5d9c59f9 SHA512 dca4aa532e21aee668807d47456537538a2b8c200b3431633ab274d3f7f1e2536686442dfe23aaeb5b0f102dc3ec649727e1064130ccffea6343b711b7dbc3a8 WHIRLPOOL 328e8924ee5d78353a1fc2ef11978c43ddab596fb7256ad0e073e48a191ac2f0f9abdcf97573c1c3b46a6c80a2a2634d9334964fb1e06519856f10d006ea34a6
AUX gitlab-ci-runner.init 1555 SHA256 a6cb0dae47109fac0758977f43bf89925337cd05f4e0313d9d5c1e1fa8ea542e SHA512 4e7b91d20e35b45a91bdb126eb43f48d03a410d9bb7dbb9b3f635a5bc96694fb3e98c73f7b7279871b0e74427dd47f448e4eae21197b24d3e8a02805cfcf3746 WHIRLPOOL 1fe9a70d2f0c2113a476a9339ceb8ac0255b7c615cb4a94ec3d0d64d186aa7102da8788b2c1935c49c9d27b02de72950460f3029b678960205fb8074fe3ca807
AUX gitlab-ci-runner.init 1554 SHA256 eb6623a0fea6cbcaff936ad62bbff0974cc30307889249ad253097af0ab87760 SHA512 bc91b7ec5490432006609effe3aa0c95aef570aef91e195301f87b858317cdf250681024186b4226eb87518aaabe83c354637c20253098cbabb82effe72e9898 WHIRLPOOL d8d17b659b16d17c81dc607feda9b85b3fb8485635e528653ea5cea94008da06681b1b8fbe50d76ce4fdf2b5ec0768ece622dc7477d45ee30c5985c17cdc90c3
DIST gitlab-ci-runner-5.0.0.tar.gz 11846 SHA256 7d7f97894ba5ffeb4f06aa8a62d1ec17c2a1cbf84efd20418d74ccfc0f18c1e5 SHA512 cee02d144f37840b215a9cf706a3ca8239fbd2f33561b783b1abfd9ebdfd2eb323ecb57b8545d08f17c50a24e237053c505257279940cef2dce60f160364875f WHIRLPOOL d79a53553221715d3a34a18bce88af5fdf02e162afb1c0ca7212707f2672e0e30f584513ac9a1b7a6b9c46b3695762fd04e2819903b05504b5f482e0047dc337
EBUILD gitlab-ci-runner-5.0.0.ebuild 6478 SHA256 fc9b8c84dbed787587eaaa637239c8617ee1c1b512319aacdd34526fbe945600 SHA512 f21ecb04db92457e42dbba10d2115b5dc39fe48777445590ed2d07fb4f9ede8ceb80738c4c81f5ba49471ed5ff9f7dba76f37dbb99150cb508e8dd4e68a0edf6 WHIRLPOOL 9ee6fd1bc2ee9765be9839e4eae16e7ce84410e68192dc7061f40d1df47353e96dabf895146d75e6fa000ab97d33d575df36170e7e4956fd268c810ec5731632
EBUILD gitlab-ci-runner-5.0.0.ebuild 6318 SHA256 730cb24c0760d1a3ee2f7eadd9080cb3def513eb5f5f345fa42ca59f8505d655 SHA512 690f2f6e058d3b6a51125fe093635e6a68184619c5a08d6f16d4f4cac65470b94f6bb011f658afc02ee9c164d37c9f3ce7e5f7d09f8cbf662ee6c695158a2d84 WHIRLPOOL a10a4f2f32207f6ffda60631cad6f39c8d109d07b03b6ed555af0b3445de8f4e4cb67fcdfb942bc41da52920b168f0cb31003f415d61ca989e528ef4f963a831

View file

@ -1,139 +0,0 @@
#! /bin/bash
### 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
APP_ROOT="/home/gitlab_ci_runner/gitlab-ci-runner"
APP_USER="gitlab_ci_runner"
PID_PATH="$APP_ROOT/tmp/pids"
PROCESS_NAME="ruby ./bin/runner"
RUNNERS_PID="$PID_PATH/runners.pid"
RUNNERS_NUM=1 # number of runners to spawn
START_RUNNER="nohup bundle exec ./bin/runner"
NAME="gitlab-ci-runner"
DESC="GitLab CI runner"
RUNNERS_REGISTERED=0
RUNNERS_RUNNING=0
INIT_LOG="/var/log/gitlab_ci_runner.log"
check_pid() {
# Number of registered runners in PID file
[ -f $RUNNERS_PID ] && RUNNERS_REGISTERED=`cat $RUNNERS_PID | wc -l`
# Number of active runner processes
RUNNERS_RUNNING=`ps -ef | grep "$PROCESS_NAME" | grep -v grep | wc -l`
echo "Number of registered runners in PID file=$RUNNERS_REGISTERED"
echo "Number of running runners=$RUNNERS_RUNNING"
}
execute() {
sudo -u $APP_USER -H bash -l -c "$1"
}
start() {
cd $APP_ROOT
check_pid
if [ "$RUNNERS_REGISTERED" -ne 0 -o "$RUNNERS_RUNNING" -ne 0 ]; then
# Program is running, Exit with error code.
echo "Error! $DESC(s) ($NAME) appear to be running already! Try stopping them first. Exiting."
exit 1
else
if [ `whoami` = root ]; then
[ ! -f $PID_PATH ] && execute "mkdir -p $PID_PATH"
[ -f $RUNNERS_PID ] && execute "rm -f $RUNNERS_PID"
# Spawn runners
for (( i=1; i<=$RUNNERS_NUM; i++ ))
do
# Check log file
if [ ! -f $INIT_LOG ]; then
touch $INIT_LOG
chown $APP_USER $INIT_LOG
fi
echo "Starting runner #$i"
execute "$START_RUNNER >> $INIT_LOG 2>&1 & echo \$! >> $RUNNERS_PID"
done
echo "SUCCESS: Started $RUNNERS_NUM $DESC(s)."
fi
fi
}
stop() {
check_pid
# Exit if there are no runners
if [ $RUNNERS_REGISTERED -eq 0 -a $RUNNERS_RUNNING -eq 0 ]; then
echo "No runners have been found. Exiting."
fi
# Runners found. Check if there are any ghost runners.
KILL_GHOSTS=0;
if [ $RUNNERS_REGISTERED -ne $RUNNERS_RUNNING ]; then
echo "WARNING: Numbers of registered runners don't match number of running runners. Will try to stop them all"
echo "Registered runners=$RUNNERS_REGISTERED"
echo "Running runners=$RUNNERS_RUNNING"
KILL_GHOSTS=1;
fi
echo -n "Trying to stop registered runners..."
if [ $RUNNERS_REGISTERED -gt 0 ]; then
execute "cat $RUNNERS_PID | xargs kill -USR2"
rm -f $RUNNERS_PID
echo "OK"
else
echo "FAILED!"
echo "Couldn't stop registered runners as there is no record of such in $RUNNERS_PID file".
fi
if [ $KILL_GHOSTS -eq 1 ]; then
echo -ne "Trying to kill ghost runners..."
ps -C "$PROCESS_NAME" -o "%p" h | xargs kill -USR2
[ $? -eq 0 ] && echo "OK"
else
echo "No ghost runners have been found.This is good."
fi
}
status() {
echo "Here is what we have at the moment:"
check_pid
}
## Check to see if we are running as root first.
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: sudo service gitlab_ci_runner {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0

View file

@ -48,7 +48,7 @@ stop() {
start-stop-daemon --stop \
--pidfile="${pidfile}"
# DO WE NEED --exec? or --startas???
local $success=$?
local success=$?
if [ ${success}!=0 ] ; then
eend ${success}
fi

View file

@ -16,7 +16,7 @@ PYTHON_DEPEND="2:2.7"
inherit eutils python ruby-ng user
DESCRIPTION="GitLab CI Runner is the vuild processor needed for GitLab CI"
DESCRIPTION="GitLab CI Runner is the build processor needed for GitLab CI"
HOMEPAGE="https://gitlab.com/gitlab-org/gitlab-ci-runner"
SRC_URI="https://github.com/gitlabhq/gitlab-ci-runner/archive/v${PV}.tar.gz -> ${P}.tar.gz"
@ -55,10 +55,7 @@ MY_USER="gitlab_ci_runner"
DEST_DIR="/opt/${MY_NAME}"
LOGS_DIR="/var/log/${MY_NAME}"
TEMP_DIR="/var/tmp/${MY_NAME}"
# When updating ebuild to newer version, check list of the queues in
# https://gitlab.com/gitlab-org/gitlab-ci/blob/v${PV}/script/background_jobs
SIDEKIQ_QUEUES="runner,common,default"
RUN_DIR="/run/${MY_NAME}"
pkg_setup() {
enewgroup ${MY_USER}