Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 24, 2016 11:52
Show Gist options
  • Save bnhansn/2cb272b40c1999e213bd508baec9abd3 to your computer and use it in GitHub Desktop.
Save bnhansn/2cb272b40c1999e213bd508baec9abd3 to your computer and use it in GitHub Desktop.
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
. /opt/elasticbeanstalk/support/envvars
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid
if [ -f ${PIDFILE} ]
then
kill -USR1 `cat ${PIDFILE}`
rm -rf /var/app/containerfiles/pids/sidekiq.pid
fi
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
"/opt/elasticbeanstalk/hooks/configdeploy/pre/03_mute_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
. /opt/elasticbeanstalk/support/envvars
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid
if [ -f ${PIDFILE} ]
then
kill -USR1 `cat ${PIDFILE}`
rm -rf /var/app/containerfiles/pids/sidekiq.pid
fi
"/opt/elasticbeanstalk/hooks/configdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
"/opt/elasticbeanstalk/hooks/restartappserver/pre/03_mute_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
. /opt/elasticbeanstalk/support/envvars
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid
if [ -f ${PIDFILE} ]
then
kill -USR1 `cat ${PIDFILE}`
rm -rf /var/app/containerfiles/pids/sidekiq.pid
fi
"/opt/elasticbeanstalk/hooks/restartappserver/post/50_restart_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
@kceb
Copy link

kceb commented Mar 1, 2019

Any reason you have to rimraf the sidekiq.pid?

rm -rf /var/app/containerfiles/pids/sidekiq.pid

Also, when do you run TERM?
https://github.com/mperham/sidekiq/wiki/Signals#term

Isn't convention to run the kill -USR1 as early as possible, like you have it, but run TERM & rm -rf sidekiq.pid on all the post hooks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment