Skip to content

AWS Beanstalk Config

Tom Harvey edited this page Mar 23, 2019 · 9 revisions

Web server environment

To restart (or just start) shoryuken on each deployment to Beanstalk, store the below in the file .ebextensions/shoryuken.config inside your repo.

# .ebextensions/shoryuken.config
# Based on the conversation in https://github.com/phstc/shoryuken/issues/48

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_shoryuken":
    mode: "000777"
    content: |
      APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
      LOG_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
      PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)

      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

      if [ -f $PID_DIR/shoryuken.pid ]
      then
        kill -TERM `cat $PID_DIR/shoryuken.pid`
        rm -rf $PID_DIR/shoryuken.pid
      fi

      sleep 10

      cd $APP_DEPLOY_DIR

      bundle exec shoryuken \
        -R \
        -P $PID_DIR/shoryuken.pid \
        -C $APP_DEPLOY_DIR/config/shoryuken.yml \
        -L $LOG_DIR/shoryuken.log \
        -d

  "/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_shoryuken":
    mode: "000777"
    content: |
      PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)
      if [ -f $PID_DIR/shoryuken.pid ]
      then
        kill -USR1 `cat $PID_DIR/shoryuken.pid`
      fi

Worker environment

For information on deploying to a worker environment see the thread in https://github.com/phstc/shoryuken/issues/48

Clone this wiki locally