Created
November 15, 2016 13:48
-
-
Save ruuts/5e023d8c1af76c52887bfe7656347bfe to your computer and use it in GitHub Desktop.
Shoryuken worker daemon for Elastic Beanstalk
This file contains 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
files: | |
"/opt/elasticbeanstalk/support/conf/shoryuken.conf": | |
mode: "000755" | |
content: | | |
description "Elastic Beanstalk Shoryuken Upstart Manager" | |
start on runlevel [2345] | |
stop on runlevel [06] | |
# explained above | |
respawn | |
respawn limit 3 30 | |
script | |
# scripts run in /bin/sh by default | |
# respawn as bash so we can source in rbenv | |
exec /bin/bash <<"EOT" | |
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir) | |
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) | |
. $EB_SUPPORT_DIR/envvars | |
. $EB_SCRIPT_DIR/use-app-ruby.sh | |
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir) | |
EB_APP_PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir) | |
cd $EB_APP_DEPLOY_DIR | |
if [ "$WORKER_ENV" = true ] | |
then | |
su -s /bin/bash -c "bundle exec shoryuken \ | |
-R \ | |
-P ${EB_APP_PID_DIR}/shoryuken.pid \ | |
-C ${EB_APP_DEPLOY_DIR}/config/shoryuken.yml \ | |
-L ${EB_APP_DEPLOY_DIR}/log/shoryuken.log" | |
fi | |
EOT | |
end script |
This file contains 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
files: | |
"/tmp/stop_shoryuken.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash | |
. /opt/elasticbeanstalk/support/envvars | |
EB_APP_PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir) | |
PIDFILE=${EB_APP_PID_DIR}/shoryuken.pid | |
if [ -f ${PIDFILE} ] | |
then | |
kill -USR1 `cat ${PIDFILE}` | |
rm -rf ${PIDFILE} | |
fi | |
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
sh /tmp/stop_shoryuken.sh | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart shoryuken || initctl start shoryuken | |
"/opt/elasticbeanstalk/hooks/configdeploy/pre/03_mute_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
sh /tmp/stop_shoryuken.sh | |
"/opt/elasticbeanstalk/hooks/configdeploy/post/50_restart_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart shoryuken || initctl start shoryuken | |
"/opt/elasticbeanstalk/hooks/restartappserver/pre/03_mute_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
sh /tmp/stop_shoryuken.sh | |
"/opt/elasticbeanstalk/hooks/restartappserver/post/50_restart_shoryuken.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart shoryuken || initctl start shoryuken |
This file contains 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
files: | |
"/etc/init/shoryuken.conf": | |
mode: "120400" | |
content: "/opt/elasticbeanstalk/support/conf/shoryuken.conf" | |
commands: | |
reload_initctl_for_shoryuken: | |
command: "initctl reload-configuration" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this in the .ebextensions/ folder in the root of your project