Rails 部署与 capistrano 并启动 resque worker



我正在使用带有 capistrano-resque gem 的 capistrano 3.2.1 在部署时重新启动 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

在我发现 capistrano-rbenv 是问题所在之后,我从我的 gemfile 和 capfile 中删除了该宝石。

然后,我只是将以下内容添加到我的 deploy.rb 文件中:

set :default_env, {
  PATH: "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH",
  RBENV_ROOT: '~/.rbenv',
  RBENV_VERSION: '2.2.2'
}

现在卡皮斯特拉诺-resque可以正常工作,独角兽等也是如此。

我根据关于capistrano-resque和capistrano-rbenv问题之间capistrano-resque不兼容的@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"

最新更新