问题
I am trying to run a simple Rails application on Heroku with some background tasks.
The application is deployed to Heroku, so I run it with Foreman locally so that things are similar to how it would work in production.
However, I cannot get Resque to start and stay up. It shuts down everytime, even without any tasks submitted.
This is how things are setup.
Gemfile (based on the github page for resque)
gem "resque", "~> 2.0.0.pre.1", github: "resque/resque"
Procfile
web: bundle exec rails server -e $RAILS_ENV -p $PORT
resque: bundle exec rake environment resque:work
When I run 'foreman start -e config/dev.env' everything starts booting up, but then Resque SIGTERMS. Here are the logs:
16:26:56 resque.1 | Loading Rails environment for Resque
16:26:56 resque.1 | D, [2014-03-12T16:26:56.237941 #22530] DEBUG -- : resque-2.0.0.pre.1: Starting
16:26:56 resque.1 | exited with code 0
16:26:56 system | sending SIGTERM to all processes
SIGTERM received
16:26:56 web.1 | [2014-03-12 16:26:56] FATAL SignalException: SIGTERM
You can see Resque booting up, then shutting down and shutting down the webserver. If I comment out 'resque' in the Procfile, the webserver boots up fine.
Any idea how to set all of this up?
回答1:
It's because the process exits and spawns the worker in the background, try to use ./bin/resque work
instead inside your Procfile
回答2:
I didn't have more time to investigate this issue. Rolling back to an old version of Resque solved it for me. All I had to do was change my Gemfile.
In my Gemfile
gem 'resque', "~> 1.22.0"
Unfortunately, this isn't Resque 2.
来源:https://stackoverflow.com/questions/22366042/how-to-setup-rails-4-resque-2-to-run-with-foreman