Last active
August 29, 2015 14:15
-
-
Save rjswenson/8897a0eb86803dd28c06 to your computer and use it in GitHub Desktop.
restart_sidekiqs.sh
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 | |
set -f | |
echo 'Iterating through all Sidekiq screens' >&2 | |
for i in $( screen -ls sidekiq| grep -o [0-9]*.sidekiq\-[a-z]*); do | |
SCREEN_ID=$(echo $i | grep -oE "(^[0-9]+)") | |
CLIENT=$(echo $i | grep -oE "([a-z]+)$") | |
echo "starting screen: ${i}" | |
read -p "Do you wish to restart <<${i}>>? [ y/n ]" prompt | |
printf "\n" | |
if [[ $prompt =~ [yY](es)* ]] | |
then | |
screen -X -S $SCREEN_ID stuff "$(printf \\003)" | |
sleep 3 | |
screen -X -S $SCREEN_ID stuff 'cd .. | |
' | |
screen -X -S $SCREEN_ID stuff 'cd current/ | |
' | |
screen -X -S $SCREEN_ID stuff "bundle exec sidekiq -q $CLIENT-staging -c 1 | |
" | |
echo "backing out of <<${CLIENT}>>" | |
printf "\n" | |
else | |
continue | |
fi | |
done | |
echo "FINISHED RESTARTING SIDEKIQ" >&2 |
Author
rjswenson
commented
Feb 17, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment