Here's what my Procfile looks like:
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
worker: bundle exec rake jobs:work
I intend to add a worker process because I wish to run some background jobs. I'm following these instructions
This is what I noticed:
- No problems encountered if the worker is started separately.
- When I keep the second line in the Procfile and don't not change anything else, the rails server serves a couple of requests and hangs after that
- As mentioned here , I've added
STDOUT.sync = true
to config/environments/development.rb and verified the same in the rails console. Did not work. - Tailed log/development.log and compared it against the stuff that foreman outputted to the shell and noticed that both matched for a couple of requests and then foreman stopped printing out stuff to the shell - the next request would then hang
- I updated foreman using foreman.pkg as mentioned here and verified the same with [6]
- It was mentioned here that this might be caused due to a stray debug statement. I'm not using the debugger and I do not have the pry gem or the ruby-debug gem in my Gemfile.lock
- I believe the symptoms are similar to this related unanswered question
Please help!
[6]:
which foreman
/usr/bin/foreman
ls -lah /usr/bin/foreman # checked the updated date
Tracked and resolved here:
https://github.com/ddollar/foreman/issues/244
TL;DR: Install the gem, don't use foreman.pkg
I'll add than if you're using Heroku, the foreman version included with the heroku toolbelt has the same issue.
Use the one you can get with gem install foreman
instead.
来源:https://stackoverflow.com/questions/11856189/rails-server-hangs-when-started-with-foreman