【问题标题】:Rails Deployment with capistrano and start resque workers使用 capistrano 部署 Rails 并启动 resque workers
【发布时间】:2018-09-21 22:48:16
【问题描述】:

我正在使用 capistrano 3.2.1 和 capistrano-resque gem 来重新启动部署时的 rasque 工作人员。总是出现这个错误。

如果我在生产服务器的当前目录下手动启动工作程序,它可以正常启动。

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

【问题讨论】:

  • 失败时会写入apps/app_production/current/log/resque.log 什么?
  • ohup:无法运行命令“RBENV_ROOT=/home/azureuser/.rbenv”:没有这样的文件或目录。这是错误日志。
  • 如果我检查 'which rbenv' 它会记录 '/home/azureuser/.rbenv/bin/rbenv'
  • @MattBrictson 提交了 github 问题。 github.com/sshingler/capistrano-resque/issues/101。您是否有其他建议来完成这项工作。 (在 cap 部署时重新启动 resque 工作人员)?
  • 降级到 0.2.1 是一种解决方法

标签: ruby-on-rails capistrano resque rbenv capistrano3


【解决方案1】:

在我发现 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 和 unicorn 等一样可以正常工作。

【讨论】:

    【解决方案2】:

    我根据 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"
    

    【讨论】:

      猜你喜欢
      • 2014-01-03
      • 2015-01-26
      • 1970-01-01
      • 2016-03-16
      • 2012-08-09
      • 2015-02-09
      • 2016-08-19
      • 2020-08-11
      • 1970-01-01
      相关资源
      最近更新 更多