Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shoryuken worker daemon for Elastic Beanstalk
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
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
files:
"/etc/init/shoryuken.conf":
mode: "120400"
content: "/opt/elasticbeanstalk/support/conf/shoryuken.conf"
commands:
reload_initctl_for_shoryuken:
command: "initctl reload-configuration"
@ruuts

This comment has been minimized.

Copy link
Owner Author

ruuts commented Nov 15, 2016

Put this in the .ebextensions/ folder in the root of your project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.