我最近在我的测试轨道应用程序中添加了capistrano,以了解capistrano的工作情况。我可以使用它来部署应用程序,但我的resque命令没有被执行。
它没有显示任何错误,但没有resque worker启动。我甚至通过登录服务器进行了检查。我尝试将capistrano中的后挂钩从deploy:restart
更改为deploy:published
。
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')
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"
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
被调用但没有任何反应。
答案 0 :(得分:0)
我可以通过更改以下代码来运行resque:
set :workers, {
ruby2: {"file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1}
}
到此:
set :workers, { "file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1}
但我仍然不知道为什么之前的代码没有运行,正如文档中提到的那样。