简体   繁体   中英

Rails/resque trouble starting foreman

I am trying to use Foreman to help run some simple background tasks for my Rails app, but am having trouble when starting my workers through foreman.

My worker is functioning properly when I start it from Terminal while running redis-server and rails server, using the following command:

bundle exec rake resque:work QUEUE=myqueue

However, I cannot get it to start up with Foreman. Here is what I have in my Procfile...

web: bundle exec rails server -p $PORT
worker: bundle exec rake resque:work QUEUE=myqueue

And I get the following when running 'foreman start' in Terminal

14:14:39 web.1    | started with pid 48120
14:14:39 worker.1 | started with pid 48121
14:14:43 worker.1 | [deprecated] I18n.enforce_available_locales will default to true in  the future. If you really want to skip validation of your locale you can set    I18n.enforce_available_locales = false to avoid this message.
14:14:43 web.1    | => Booting WEBrick
14:14:43 web.1    | => Rails 4.0.3 application starting in development on http://0.0.0.0:5000
14:14:43 web.1    | => Run `rails server -h` for more startup options
14:14:43 web.1    | => Ctrl-C to shutdown server
14:14:43 worker.1 | D, [2014-04-18T14:14:43.561321 #48121] DEBUG -- : resque-2.0.0.pre.1:  Starting
14:14:43 worker.1 | exited with code 0
14:14:43 system   | sending SIGTERM to all processes
14:14:43 web.1    | Exiting
14:14:43          | D, [2014-04-18T14:14:43.568351 #48138] DEBUG -- : Registered signals
14:14:43          | I, [2014-04-18T14:14:43.574222 #48138]  INFO -- : Running before_first_fork hooks with [#<Worker Jacks-MacBook-Pro.local:48138:pledges>]
14:14:43 web.1    | terminated by SIGTERM

I can start up foreman when I remove the 'worker:' line from my Procfile, so I'm thinking it must be an issue with that line.

I'm using Rails 4.0.3 and Resque 2.0.0

Is your Worker running as a daemon? When you run bundle exec rake resque:work QUEUE=myqueue is it running in the background and return to your shell prompt? Foreman doesn't play at all with daemon processes and resque workers can be configured to run as BACKGROUND=true.

If the worker is running in the background, disable this behavior and let foreman manage the process.

If foreman loses the connection to the process it spawned, it will kill all other processes it started from the procfile because it thinks it failed.

What's also troubling is this line:

14:14:43 worker.1 | D, [2014-04-18T14:14:43.561321 #48121] DEBUG -- : resque-2.0.0.pre.1:  Starting

It looks like you're using Resque 2.0. Is there a stable release of this yet?

Also Related:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM