Skip to content
Browse files

Add a script to monitor if Sidekiq is running and start it if not

  • Loading branch information...
1 parent 1511173 commit fd5feda70058ab0e675f11d23e9526a400598c7f @mitio mitio committed
Showing with 24 additions and 0 deletions.
  1. +24 −0 ensure_sidekiq_is_running.sh
View
24 ensure_sidekiq_is_running.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+project_root=`dirname "$0"`
+pid_file="$project_root/tmp/pids/sidekiq.pid"
+pid=`cat "$pid_file" 2>/dev/null`
+sidekiq_is_running=""
+
+if [ -n "$pid" ]
+then
+ if ps $pid 2>&1 | grep sidekiq > /dev/null
+ then
+ sidekiq_is_running="yes"
+ fi
+fi
+
+if [ -z "$sidekiq_is_running" ]
+then
+ echo "Sidekiq is not running, trying to start it..."
+ cd $project_root
+ nohup bundle exec sidekiq -e production -C "$project_root/config/sidekiq.yml" -P $pid_file >> "$project_root/log/sidekiq.log" 2>&1 &
+ echo "Sidekiq started."
+else
+ echo "Sidekiq is alive."
+fi

0 comments on commit fd5feda

Please sign in to comment.
Something went wrong with that request. Please try again.