问题
On my local machine I'm trying to start my rails app and delayed job worker using Foreman. My Procfile looks like this:
web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
When I start foreman only the first two web requests get executed. With the third request the server hangs. The first request is outputted in the console, the second isn't.
If I leave out the worker in my Procfile the server is running just fine and is outputting everything to the console. Also when I start the rails server and worker without Foreman everything is working fine.
So it looks like there's an issue with Foreman. I'm guessing it's a problem with Foreman not outputting anything to the console after the first request and therefore the buffer doesn't get flushed. I've searched other posts and as a result added STDOUT.sync = true to my development.rb but without any success.
Does anybody have a clue? Thanks!
回答1:
UPDATE: Tracked and resolved here:
https://github.com/ddollar/foreman/issues/244
TL;DR: Install the gem, don't use foreman.pkg
I'm facing the same problem.
Here's a link to the question I've asked on stackoverflow. @smek, if you found an answer, please reply!
回答2:
I had a similar problem when trying to implement and test DJ + Foreman in my local dev environment. I intended to deploy to Heroku and was using the following article as a guide. If you are also deploying to Heroku, I recommend installing Heroku Toolbelt, which includes Foreman. In my case I already had Heroku Toolbelt installed, so I simply reinstalled it.
回答3:
most of the times someone left a debugger/pry statement in the code or you put a breakpoint in somewhere.
if you can't find anything than you can use system tools like lsof or gdb to find out what your ruby process is doing at the moment. that might help finding the problem.
回答4:
I just started using Foreman about an hour ago, and I was having some issues with both my rake tasks and rails server
hanging when being run by Foreman. When I removed the pry
gem from my Gemfile it worked, but that wasn't acceptable since I use pry in development.
Then I updated to foreman version 0.49.0 (which was released about 10 minutes ago) and the problem was fixed. Too bad I didn't start working on this task an hour later, because then I would have gotten 0.49.0 to start with and not had to mess around for an hour :)
You should try upgrading Foreman and see if it fixes your problem.
来源:https://stackoverflow.com/questions/11359940/rails-foreman-worker-hangs-server