How to setup Rails 4, Resque 2 to run with Foreman?

余生颓废 提交于 2019-12-12 04:18:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!