Created
February 23, 2015 13:49
-
-
Save loa/115294d02be03838bf5c to your computer and use it in GitHub Desktop.
Gitlab Sidekiq Zombie Apocalypse Crontab Sentry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/bin/bash +xe | |
| exec 1> >(logger -s -t $0) 2>&1 | |
| # Load RVM into a shell session *as a function* | |
| [[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" | |
| num_zombies=$(ps aux | grep defunct | grep -v grep | wc -l) | |
| [ ${num_zombies} -eq 0 ] && { | |
| echo "Found no zombies" | |
| } || { | |
| echo "Found ${num_zombies} zombies, restarting sidekiq" | |
| hipchat "Found ${num_zombies} zombies, restarting sidekiq" | |
| RAILS_ENV=production su git -c '/home/git/gitlab/bin/background_jobs restart' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment