如何获得修复'需要'的错误设置delayed_job的弹性魔豆时 [英] How to get fix 'require' errors when setting up delayed_job on Elastic Beanstalk
问题描述
我有弹性魔豆运行的麻烦delayed_jobs。我使用的 64位的Linux亚马逊V1.0.0 2014.03运行的Ruby 2.1(乘客独立)容器。
I'm having trouble getting delayed_jobs running on Elastic Beanstalk. I'm using the 64bit Amazon Linux 2014.03 v1.0.0 running Ruby 2.1 (Passenger Standalone) container.
这是我的配置脚本(delayed_job.config)...
This is my config script (delayed_job.config) ...
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
mode: "000755"
owner: root
group: root
encoding: plain
content: |
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
cd $EB_CONFIG_APP_CURRENT
su -c "RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
在 99_restart_delayed_job.sh
脚本存在并运行......但后来我跌入这个错误。
The 99_restart_delayed_job.sh
script exists and runs ... but then I stumble into this error.
2014-10-02 15:28:32,332 [INFO] (17387 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-10-02 15:28:32,402 [INFO] (17448 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing directory: /opt/elasticbeanstalk/hooks/appdeploy/post/
2014-10-02 15:28:32,402 [INFO] (17448 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh
/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/app/current/config/boot.rb:4:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/app/current/config/application.rb:1:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/app/current/config/environment.rb:2:in `<top (required)>'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from bin/delayed_job:3:in `<main>'
2014-10-02 15:28:32,440 [ERROR] (17448 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh failed with returncode 1
我已经通过<一个已经倒href="http://stackoverflow.com/questions/14401204/how-to-automatically-restart-delayed-job-when-deploying-a-rails-project-on-amazo">this在SO 的向我展示了如何设置其他线程。我的问题是,我不知道什么是$ P $从无差错运行pventing脚本。
I've already poured through this other thread on SO that showed me how to set up. My problem is that I don't know what's preventing the script from running without error.
如果我SSH到EC2实例,我能够无差错运行此...
If I SSH into the EC2 instance, I'm able to run this without error ...
RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart
虽然这个要求我输入密码...
While this asks me for a password ...
su -c "RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
我可以通过这样做可以避免...
Which I can avoid by doing this ...
sudo su -c "RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
请参阅:<一href="http://stackoverflow.com/questions/14401204/how-to-automatically-restart-delayed-job-when-deploying-a-rails-project-on-amazo">'How部署在Amazon Elastic魔豆Rails项目时自动重新启动的delayed_job?
更新1:2014年10月15日
将与目录的传入的变化 -l </ code>选项后,我得到这个错误...
After applying the -l
option with the change of directory passed in, I get this error ...
2014-10-15 06:17:28,673 [INFO] (4417 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh
2014-10-15 06:17:30,374 [INFO] (4417 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:393:in `kill': Operation not permitted (Errno::EPERM)
from /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:393:in `stop'
from /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application_group.rb:171:in `block (2 levels) in stop_all'
2014-10-15 06:17:30,374 [ERROR] (4417 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh failed with returncode 1
更新2:2014年10月15日
原来上面由根创建的现有PID导致错误(在调试时我的delayed_job手动启动),使C2用户无法重新启动/杀死它,因此错误。
Turns out the error above was caused by an existing pid created by root (while debugging I had started delayed_job manually) so the c2-user couldn't restart/kill it hence the error.
推荐答案
的问题,从我可以告诉,是环境/路径变量没有被确定切换到时候, $ EB_CONFIG_APP_USER
Linux用户。我做了三个转变:
The problem, from what I can tell, is that the environment/path variables aren't being established when switching to the $EB_CONFIG_APP_USER
linux user. I made three changes:
- 添加
-l </ code>选项到
苏
命令模拟的完整登录$ EB_CONFIG_APP_USER
。 - 作为
-l </ code>选项的副作用,更改目录命令必须被带进
-c
选项。 - 作为一个很好的措施,但也许不是必要的,包括
捆绑EXEC
,以确保正确的宝石被使用。
- Add the
-l
option to thesu
command to simulate a full login of$EB_CONFIG_APP_USER
. - As a side effect of the
-l
option, the change directory command must be brought into the-c
option. - As a good measure, but maybe not necessary, include
bundle exec
to ensure that the proper gems are being used.
下面是我的正常工作内容:
区:
Here's my functioning content:
area:
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
su -l -c "cd $EB_CONFIG_APP_CURRENT && RAILS_ENV=production bundle exec bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
这篇关于如何获得修复'需要'的错误设置delayed_job的弹性魔豆时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!