我使用capistrano 3.2.1和capistrano-resque gem在部署时重启rasque worker。总是得到这个错误。
如果我在生产服务器上的当前目录下手动启动工作程序,它就会正常运行。
cd /home/azureuser/apps/app_production/current && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 /usr/bin/env nohup RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec bundle exec rake RACK_ENV=production RAILS_ENV=production QUEUE="mailer" PIDFILE=/home/azureuser/apps/app_production/shared/tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work >> log/resque.log 2>> log/resque.log )
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as azureuser@thesend.cloudapp.net: nohup exit status: 127
nohup stdout: Nothing written
nohup stderr: Nothing written
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: nohup exit status: 127
答案 0 :(得分:0)
在我解决了capistrano-rbenv问题之后,我从我的gemfile和我的capfile中删除了那个gem。
然后我将以下内容添加到我的deploy.rb文件中:
set :default_env, {
PATH: "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH",
RBENV_ROOT: '~/.rbenv',
RBENV_VERSION: '2.2.2'
}
现在,capistrano-resque和独角兽等一样正常工作。
答案 1 :(得分:0)
我根据Capistrano-resque incompatibility between capistrano-resque and capistrano-rbenv issue上的@archfish建议修复此问题。然后,您应该在deploy.rb上添加或修改:rbenv_prefix
,例如:
set :rbenv_prefix, "env RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
注意::rbenv_prefix
的用法通常是:
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"