Skip to content

Instantly share code, notes, and snippets.

@jpsilvashy
Last active May 29, 2018 23:47
Show Gist options
  • Save jpsilvashy/7525250da665f01a00571f944d1c2d04 to your computer and use it in GitHub Desktop.
Save jpsilvashy/7525250da665f01a00571f944d1c2d04 to your computer and use it in GitHub Desktop.
ElasticBeanstalk que upstart job and and post deploy script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/etc/init/que.conf":
mode: "000755"
owner: root
group: root
content: |
description "Que Upstart Manager"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
exec /bin/bash <<"EOF"
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)
cd $EB_APP_DEPLOY_DIR
exec su -s /bin/bash -c "bundle exec que" webapp
EOF
end script
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_que.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
initctl start que || initctl restart que
description "Que Upstart Manager"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
exec /bin/bash <<"EOF"
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)
cd $EB_APP_DEPLOY_DIR
exec su -s /bin/bash -c "bundle exec que" webapp
EOF
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment