wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

Restart resque workers on deployment #37

Closed joshuapaling closed 10 years ago

joshuapaling commented 10 years ago

Hi,

I've got a staging and production site, both on the same server. They use CakeResque. I'm using Capistrano for deployment. I've got a capistrano task that executes each deployment, to stop / start all resque workers:

  # Stop all first. If we instead use restart, for some reason
  # it creates one extra worker each deploy.
  # ie, after 10 deploys, there'll be 10 workers
  desc "Re-Start CakeResque Workers"
  task :restart_resque_workers, :roles => :app do
    run "#{latest_release}/app/Console/cake CakeResque.CakeResque stop -a"
    run "#{latest_release}/app/Console/cake CakeResque.CakeResque start"
  end

The deployment works, and the terminal output shows that Resque appeared to start a worker correctly. However, that worker won't pick up any jobs allocated to it.

After deployment, if I manually execute eg.

cap staging deploy:restart_resque_workers

that is, if I just restart the workers and don't do a full deployment, then it all works OK, and the worker will pick up jobs.

Except that if I restart the workers via the staging path:

cap staging deploy:restart_resque_workers

then the production site's workers no longer pick up jobs. And likewise, if I restart the production workers, they'll pick up jobs, but the staging site's workers will stop picking up jobs.

Any idea what's going on? Should the staging / production sites, and their workers, be able to run site-by-side on the same server without interrupting one another?

And any idea why restarting as part of the normal capistrano process appears to work, but the workers don't pick up jobs?

Thanks for any help, and thanks for a great plugin!

wa0x6e commented 10 years ago

What's the log saying ?

The classic issue is that your workers have a permission problem.

joshuapaling commented 10 years ago

I had things set up so my logs and other temp files were deleted on each new deploy - so at the moment I can't tell what the logs say. I'll fix that now and then see if I can get it working.

joshuapaling commented 10 years ago

Ok, I've upgraded to the latest version of the plugin, and set it up so that the Staging and Production databases use different Redis databases (before they were both using database 0).

Things seem to be behaving correctly now.