我已经安装了Redis / Resque,但是当我部署时,我很难从Capistrano开始/重新启动它。
我的需求相当简单:我只有1个队列,只需要1个工人,而且我不使用monit或god。
基于this blog post,我的deploy.rb包含:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
task :restart_resque do
pid_file = "#{shared_path}/pids/resque.pid"
run "test -f #{pid_file} && cd #{current_path} && kill -s QUIT `cat #{pid_file}` || rm -f #{pid_file}"
run "cd #{current_path}; RAILS_ENV=production QUEUE='*' VERBOSE=1 nohup rake environment resque:work& > #{shared_path}/log/resque.log && echo $! > #{pid_file}"
end
end
after 'deploy:restart', 'deploy:restart_resque'
我的resque.rake文件(基于Railscast)有:
require "resque/tasks"
task "resque:setup" => :environment
当我cap deploy
时,一切似乎都有效,但当我查看resque-web时,没有工人在运行......