summaryrefslogtreecommitdiff
path: root/script/background_jobs
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-10-09 16:45:32 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-10-15 22:48:57 +0200
commit6a7d63aa47d583a21b87b623a010d8b98abb8777 (patch)
tree682fd8e0bb7314a82339da69be6442cb1e037971 /script/background_jobs
parent7c4db532ff246a9831a5decaaf031affeb1eb21d (diff)
downloadgitlab-ce-6a7d63aa47d583a21b87b623a010d8b98abb8777.tar.gz
Move unicorn and sidekiq commands into bash script
Diffstat (limited to 'script/background_jobs')
-rwxr-xr-xscript/background_jobs56
1 files changed, 56 insertions, 0 deletions
diff --git a/script/background_jobs b/script/background_jobs
new file mode 100755
index 00000000000..e0beb3df815
--- /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_user=$(ls -l config.ru | awk '{print $3}')
+
+function stop
+{
+ bundle exec sidekiqctl stop $sidekiq_pidfile &>> $sidekiq_logfile
+}
+
+function killall
+{
+ pkill -u $gitlab_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 post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ &>> $sidekiq_logfile
+}
+
+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