summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-01-29 14:16:08 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-01-29 14:36:55 +0100
commit609f226a281c1ec8319b1259835703eb6d96d3cf (patch)
tree40c4062f9a634d5730946c3e88ed665b20cf7d06
parent8cc92d3c61e0356d1cc466f77837d0ef9e0eeb86 (diff)
downloadgitlab-ci-609f226a281c1ec8319b1259835703eb6d96d3cf.tar.gz
Add background_jobs script from gitlabhq
-rw-r--r--lib/support/init.d/gitlab_ci4
-rwxr-xr-xscript/background_jobs56
2 files changed, 58 insertions, 2 deletions
diff --git a/lib/support/init.d/gitlab_ci b/lib/support/init.d/gitlab_ci
index ced0412..11ceadd 100644
--- a/lib/support/init.d/gitlab_ci
+++ b/lib/support/init.d/gitlab_ci
@@ -22,8 +22,8 @@ SOCKET_FILE="$SOCKET_PATH/gitlab-ci.socket"
PID_PATH="$APP_ROOT/tmp/pids"
WEB_SERVER_PID="$PID_PATH/puma.pid"
SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
-STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
-START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
+STOP_SIDEKIQ="RAILS_ENV=production script/background_jobs stop"
+START_SIDEKIQ="RAILS_ENV=production script/background_jobs start"
SIDEKIQ_LOG="$APP_ROOT/log/sidekiq.log"
NAME="GitLab CI"
DESC="Gitlab CI service"
diff --git a/script/background_jobs b/script/background_jobs
new file mode 100755
index 0000000..6847869
--- /dev/null
+++ b/script/background_jobs
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+cd $(dirname $0)/..
+app_root=$(pwd)
+sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid"
+sidekiq_logfile="$app_root/log/sidekiq.log"
+gitlab_ci_user=$(ls -l config.ru | awk '{print $3}')
+
+function stop
+{
+ bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1
+}
+
+function killall
+{
+ pkill -u $gitlab_ci_user -f sidekiq
+}
+
+function restart
+{
+ if [ -f $sidekiq_pidfile ]; then
+ stop
+ fi
+ killall
+ start_sidekiq -d -L $sidekiq_logfile
+}
+
+function start_no_deamonize
+{
+ start_sidekiq
+}
+
+function start_sidekiq
+{
+ bundle exec sidekiq -q runner,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1
+}
+
+case "$1" in
+ stop)
+ stop
+ ;;
+ start)
+ restart
+ ;;
+ start_no_deamonize)
+ start_no_deamonize
+ ;;
+ restart)
+ restart
+ ;;
+ killall)
+ killall
+ ;;
+ *)
+ echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}"
+esac