0

I'm trying to run heroku CLI commands like:

heroku run rake db:migrate --app app-name
heroku run rake db:seed --app app-name

from a Resque worker running in the background.

If I run the worker in the foreground with:

RAILS_ENV=production rake resque:work QUEUE="*"

the process completes successfully, and the rake tasks are run.

However, when the worker is started like so:

RAILS_ENV=production PIDFILE=./resque.pid BACKGROUND=yes QUEUE="*" rake resque:work >>  worker1.log

the processes silently fail with no indication of what happened in the logs. Is there a way to run these tasks in the background?

Josh Tate
  • 23
  • 1
  • 5
  • Why would you execute these tasks from a worker? Both migrations and seeding should be done by the manually by the developer after pushing a migration - who should ensure that migration and seeding is successful. Sorry if I'm being contrarian but i just can't see why you would want to do this. – max Oct 07 '15 at 18:46

1 Answers1

0

Like max said I'm not sure why you would want to do this, but if you want to invoke a Rake task from a Ruby script, in your case it is better to actually load the Rake task into memory and run it from within your Resque worker. Here is a SO answer that explains how to run a Rake task from Ruby: https://stackoverflow.com/a/15259172/586983

Community
  • 1
  • 1
jakeonrails
  • 1,885
  • 15
  • 37