Mongrel + nginx + fork

I’m trying to kick off simple (yet long running) background processes
from within my rails app. I’m using Tom Anderson’s spawn plugin
http://rubyforge.org/projects/spawn/ to fork a child process and unhook
the active record DB connections to keep rails happy. Anyway,
everything works great when I hit a mongrel process directly
(http://myapp:3000/controller/action). The action quickly executes, the
results are returned to my browser, and the child process takes its time
doing the heavy lifting. I can hit that mongrel process again and
verify that it’s free to serve up another request.

Life is good-- that is until, I bring nginx into the mix. With nginx
proxying to the upstream :3000 mongrel, the response isn’t immediately
returned to my browser. Instead, the rails log file shows that the
request is finished, but my browser continues to spin, waiting for the
response. If I stop the request, I can load an alternate action to
verify that the lone mongrel is free to serve another request.

Has anyone had success with nginx, mongrel, and child processes? I just
installed pen to balance the single mongrel, and it worked as expected.

My dev box is intel mac, ruby 1.8.6, mongrel 1.1.2, nginx 0.5.34 (tried
with same results on 0.5.32)

Thanks!

Hi,

You could try background_fu[1] or Backgroundrb[2] for long running
background processes.

[1] -> https://svn.trix.pl/public/background_fu/README
[2] -> http://backgroundrb.rubyforge.org/

On Dec 20, 5:10 am, Nicky Be [email protected]
wrote:

proxying to the upstream :3000 mongrel, the response isn’t immediately

Thanks!


Aurelian

http://www.locknet.ro

aurelian wrote:

Hi,

You could try background_fu[1] or Backgroundrb[2] for long running
background processes.

Thanks for the suggestions; I had seen BackgroundRb, but background_fu
looks much lighter. I was hoping to stay away from running a daemon to
ease deployment issues. If I can’t figure out the nginx issue, I might
have to go that route, but I was really hoping fork would get me there.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs