部署Sidekiq到Ubuntu我在這裏跟隨方向Sidekiq與Capistrano的Ubuntu的整合:https://github.com/mperham/sidekiq/wiki/Deploying-to-Ubuntu錯誤使用Capistrano的
我在與Capistrano的一部分的問題。
我把這個代碼在deploy.rb
末:
# For capistrano 3
namespace :sidekiq do
task :quiet do
# Horrible hack to get PID without having to use terrible PID files
puts capture("kill -USR1 $(sudo initctl status workers | grep /running | awk '{print $NF}') || :")
end
task :restart do
execute :sudo, :initctl, :restart, :workers
end
end
after 'deploy:starting', 'sidekiq:quiet'
after 'deploy:reverted', 'sidekiq:restart'
after 'deploy:published', 'sidekiq:restart'
當我運行cap production deploy
我得到這個錯誤:
cap aborted!
NoMethodError: undefined method `capture' for main:Object
config/deploy.rb:67:in `block (2 levels) in <top (required)>'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/dsl.rb:15:in `invoke'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/tasks/framework.rake:65:in `block (2 levels) in <top (required)>'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/tasks/framework.rake:64:in `each'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/tasks/framework.rake:64:in `block in <top (required)>'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/Users/user/.rvm/gems/[email protected]/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/Users/user/.rvm/gems/[email protected]/bin/cap:23:in `load'
/Users/user/.rvm/gems/[email protected]/bin/cap:23:in `<main>'
/Users/user/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `eval'
/Users/user/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sidekiq:quiet
(See full trace by running task with --trace)
The deploy has failed with an error: #<NoMethodError: undefined method `capture' for main:Object>
顯然,這是捕獲功能這是不確定的,但什麼是問題?我把代碼放在正確的文件deploy.rb
?我需要什麼嗎?
這是爲什麼downvoted?根據https://github.com/mperham/sidekiq/blob/71e523757e18cb2483703429613b268dd262415a/lib/sidekiq/web_helpers.rb該方法在Sidekiq模塊中定義,因此要求模塊應該修復它。 – 2015-04-02 08:17:02
@NekoNova我試着要求在'deploy.rb'頂部有'require'sidekiq''的模塊。 'sidekiq'已經在我的Gemfile中。仍然有'NoMethodError:未定義的方法'捕獲'爲主:對象'。嘗試將其更改爲'Sidekiq.capture',但這也不起作用。你確定捕獲方法不是這種方法:https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Inspection-Capture? – 2015-04-02 08:47:01
也可以。如果您使用Capistrano的完整模塊表示法來調用它,它會工作嗎?你是否使用bundle exec調用rake任務? – 2015-04-02 08:52:54