【发布时间】:2017-07-08 02:39:06
【问题描述】:
我意识到有一些关于此的文章,但我正在尝试在 Elastic Beanstalk 上部署 Rails 应用程序并在部署过程中启动延迟作业,但我还没有设法让它工作。
我尝试在 .ebextensions 文件夹中设置一个配置文件:
命令: 创建后目录: 命令:“mkdir /opt/elasticbeanstalk/hooks/appdeploy/post” 忽略错误:真
文件: “/opt/elasticbeanstalk/hooks/appdeploy/post/restart_delayed_job.sh”: 模式:“000755” 所有者:根 组:根 内容:| #!/usr/bin/env bash
# Loading environment data
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
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)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
# Export EB_APP_LOG_DIR so we can access it when running bin/delayed_job below,
# which accesses config/initializers/delayed_job.rb, which uses EB_APP_LOG_DIR.
export EB_APP_LOG_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
# Make sure the delayed_job.log exists and is owned by $EB_APP_USER
touch $EB_APP_LOG_DIR/delayed_job.log
chown $EB_APP_USER:$EB_APP_USER $EB_APP_LOG_DIR/delayed_job.log
# Setting up correct environment and ruby version so that bundle can load all gems
. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh
# Now we can do the actual restart of the worker. Make sure to have double quotes when using env vars in the command.
# For Rails 4, replace script/delayed_job with bin/delayed_job
cd $EB_APP_DEPLOY_DIR
su -s /bin/bash -c "bundle exec bin/delayed_job --pid-dir=$EB_APP_PID_DIR restart" $EB_APP_USER
su -s /bin/bash -c "bundle exec bin/delayed_job --pid-dir=$EB_APP_PID_DIR status" $EB_APP_USER
非常感谢任何帮助使其正常工作!
【问题讨论】:
-
这个运气好吗?
标签: ruby-on-rails amazon-elastic-beanstalk delayed-job