我在Elastic Beanstalk上運行delayed_jobs時遇到問題。我正在使用運行Ruby 2.1(Passenger Standalone)容器的64位Amazon Linux 2014.03 v1.0.0的容器。如何在Elastic Beanstalk上設置delayed_job時修復'require'錯誤
這是我的配置腳本(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
腳本存在和運行......但後來我跌入這個錯誤。
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
我已經傾注了this other thread on SO,告訴我如何設置。我的問題是,我不知道什麼阻止腳本無誤地運行。
如果我SSH到EC2實例,我能夠運行沒有錯誤此...
RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart
雖然這要求我輸入密碼...
su -c "RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
我哪通過這樣做避免...
sudo su -c "RAILS_ENV=production bin/delayed_job --pid-dir=$EB_CONFIG_APP_SUPPORT/pids restart" $EB_CONFIG_APP_USER
更新1:2014年10月15日
與傳遞,我得到這個錯誤目錄的變化賦予了-l
選項後...
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
發現上面的錯誤是由root創建的現有pid導致的(在調試時我手動啓動了delayed_job),所以c2用戶無法重新啓動/終止它,從而導致錯誤。
我申請更改建議,並得到了新的錯誤(見更新的問題),但是,是的,你的建議是有道理的。這當然指向了正確的方向,所以我必須通過SSH進入我的實例,然後手動完成,直到出現問題。將更新進度。 – 2014-10-15 06:27:28
您的錯誤似乎表明'$ EB_CONFIG_APP_USER'沒有權限停止正在運行的進程。確保'bin/delayed_job'沒有以前面的故障排除步驟的root身份在後臺運行。同時驗證'bin/delayed_job'的文件權限。 – 2014-10-15 15:59:30
顯然環境變量隨着下一個Beanstalk(2014.09)而消失。 [此AWS論壇主題]的解決方法(https://forums.aws.amazon.com/thread.jspa?messageID=602937)。有關[本答案](http://stackoverflow.com/a/28506920/550712)和[本博客文章](http://www.dannemanne.com/posts/post-deployment_script_on_elastic_beanstalk_restart_delayed_job)中新方法的delayed_job詳細信息, 。 – 2015-02-19 02:03:45