在 Rails 3 应用程序中 cap:deploy 后,Resque 未启动

Resque not starting after cap:deploy in Rails 3 app

我最近将 capistrano 添加到我的测试 rails 应用程序中以了解 capistrano 的工作原理。我可以使用它部署应用程序,但我的 resque 命令没有被执行。

它没有显示任何错误,但没有启动 resque worker。我什至通过登录服务器进行了检查。我尝试将 capistrano 中的后挂钩从 deploy:restart 更改为 deploy:published

deploy.rb

lock '3.6.1'

set :application, 'test_app'
set :repo_url, 'sample_url.git'
set :resque_log_file, "log/resque.log"

set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

config/deploy/capistrano_test.rb

set :use_sudo, true

server 'ruby2', user: 'ubuntu', roles: %w{web app db}
set :ssh_options, { forward_agent: true }

set :branch, 'capistrano_test'
set :deploy_to, '/var/www/test_cap'

role :resque_worker, 'ruby2'

set :workers, { 
    ruby2: {"file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1} 
}

after "deploy:restart", "resque:restart"

Capfile

require "capistrano/setup"

require "capistrano/deploy"

require "capistrano/rvm"
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rake'
require "capistrano-resque"

Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

日志

** Invoke deploy:published (first_time)
** Execute deploy:published
** Invoke resque:restart (first_time)
** Execute resque:restart
** Invoke resque:stop (first_time)
** Execute resque:stop
** Invoke resque:start (first_time)
** Execute resque:start
** Invoke deploy:finishing (first_time)
** Execute deploy:finishing
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
01:23 deploy:cleanup
      Keeping 5 of 6 deployed releases on ruby2
      01 rm -rf /var/www/test_cap/releases/20161111045128
    ✔ 01 ubuntu@ruby2 3.018s
** Invoke deploy:finished (first_time)
** Execute deploy:finished
** Invoke deploy:log_revision (first_time)
** Execute deploy:log_revision
01:28 deploy:log_revision
      01 echo "Branch capistrano_test (at af938c9c04998d97176886462eac94701292bcfd) deployed as release 20161114030844 by venkat" >> /var/www/test_ca…
    ✔ 01 ubuntu@ruby2 1.909s

resque:restart 正在调用,但没有任何反应。

我能够 运行 通过更改以下代码重新请求:

set :workers, { 
    ruby2: {"file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1} 
}

对此:

set :workers, { "file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1}

但是我还是不明白为什么之前的代码没有运行,正如文档中提到的那样。