How to automatically restart delayed_job when deploying a rails project on Amazon Elastic Beanstalk?

后端 未结 4 1031
走了就别回头了
走了就别回头了 2020-12-05 05:42

I\'m hosting a rails project on Amazon Elastic Beanstalk and I try to configure a container command to automatically restart my delayed_job worker on the server after each d

4条回答
  •  旧巷少年郎
    2020-12-05 06:12

    In case anybody is looking to get delayed_job working in latest ElasticBeanstalk (64bit Amazon Linux 2014.09 v1.0.9 running Ruby 2.1 (Puma)): I got it to work using the below code (Thanks to damontorgerson). This file goes in ruby.config in .ebextensions folder.

    # Install git in order to be able to bundle gems from git
    packages:
    yum:
      git: []
    
    files: 
      "/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_delayed_job":
        mode: "000777"
        owner: root
        group: root
        content: |
          EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
          EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
          EB_CONFIG_APP_CURRENT=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
          EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
          EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
          EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
          EB_CONFIG_APP_PIDS=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)
    
          . $EB_SUPPORT_DIR/envvars
          . $EB_SCRIPT_DIR/use-app-ruby.sh
    
          cd $EB_CONFIG_APP_CURRENT
    
          . $EB_SUPPORT_DIR/envvars.d/sysenv
    
          bin/delayed_job --pid-dir=/var/tmp restart
    

提交回复
热议问题