如何使用queue_classic
gem在EC2上设置rubber
个后台作业?
我尝试使用工头导出,但我不知道在哪里运行它(应用程序或Web角色?)。
我失败的尝试是使用http://blog.sosedoff.com/2011/07/24/foreman-capistrano-for-rails-3-applications/。
我应该创建一个新实例来运行这些工作吗? (或新角色?)
感谢您的帮助!
答案 0 :(得分:1)
想出来。
首先使用queue_classic rake任务创建一个Procfile(参见http://blog.daviddollar.org/2011/05/06/introducing-foreman.html)
然后我将foreman添加到我的主机(确保你有一个针对该环境的proc文件,例如:Procfile.production)
# Foreman tasks
namespace :foreman do
desc 'Export the Procfile to Ubuntu upstart scripts'
task :export, :roles => :queue do
run "cd #{release_path} && bundle exec foreman export upstart /etc/init -f ./Procfile.#{Rubber.env} -a #{application} -u #{user} -l #{release_path}/log/foreman"
end
desc "Start the application services"
task :start, :roles => :queue do
rsudo "start #{application}"
end
desc "Stop the application services"
task :stop, :roles => :queue do
rsudo "stop #{application}"
end
desc "Restart the application services"
task :restart, :roles => :queue do
rsudo "stop #{application}; start #{application}"
#run "sudo start #{application} || sudo restart #{application}"
end
end
after "deploy:update", "foreman:export" # Export foreman scripts
before "deploy:restart", "foreman:restart" # Restart application scripts
after "deploy:stop", "foreman:stop" # Restart application scripts