Created
May 27, 2010 02:37
-
-
Save tsmango/415372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| # Restart Passenger | |
| deploy.task :restart, :roles => :app do | |
| ... | |
| # Restart the resque workers | |
| run "cd #{current_path} && rake queue:restart_workers RAILS_ENV=production" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :queue do | |
| task :restart_workers => :environment do | |
| pids = Array.new | |
| Resque.workers.each do |worker| | |
| pids << worker.to_s.split(/:/).second | |
| end | |
| if pids.size > 0 | |
| system("kill -QUIT #{pids.join(' ')}") | |
| end | |
| system("rm /var/run/god/resque-1.8.0*.pid") | |
| end | |
| end |
Author
Awesome, that's what I was thinking. Many thanks again!
Kimball
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good questions.
I believe that removing the /var/run/god/resque-1.8.0.pid file and running sudo god terminate resque have two different effects.
When you remove the /var/run/god/resque-1.8.0.pid file, god just fires up a new resque worker based on your config.
When you call sudo god terminate resque, I would image it just terminates resque based on the process id in your pid file in /var/run/god. I've never used god terminate, though, so I don't know if your process is automatically restarted or not after running terminate. Regardless, if you use god to terminate resque, it would only know to kill the one process and it would probably leave the second, related process running which could cause issues (but don't hold me to that).
In the last line of my rake task, I do:
What's important to note here is that the first part of that, the kill -QUIT #{pids.join(' ')} is the part that actually kills off the resque workers. The second part after the && is a second command to remove the pid file god knew about. By removing that pid file, it simply lets god know that it should fire up resque again. Removing the pid file doesn't actually quit anything, it just tells god to start it again.
So yes, since you're running multiple resque workers I would chnage that to read:
Good luck!