unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* workers created when request comes in?
@ 2009-12-16  1:37 Joseph McDonald
  2009-12-16  2:37 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph McDonald @ 2009-12-16  1:37 UTC (permalink / raw)
  To: mongrel-unicorn

Is it possible to have unicorn spawn a new worker when a request comes
in, and only allow that child to service the one request?

In development mode it would be nice if I could just save my changes
and know that I will see them right away without having to HUP the
server.

thanks,
-joe
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: workers created when request comes in?
  2009-12-16  1:37 workers created when request comes in? Joseph McDonald
@ 2009-12-16  2:37 ` Eric Wong
       [not found]   ` <73096a160912152148l4eea211eq972fcea3ebdf9112@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2009-12-16  2:37 UTC (permalink / raw)
  To: Joseph McDonald; +Cc: unicorn list

Joseph McDonald <superjoe@gmail.com> wrote:
> Is it possible to have unicorn spawn a new worker when a request comes
> in, and only allow that child to service the one request?
> 
> In development mode it would be nice if I could just save my changes
> and know that I will see them right away without having to HUP the
> server.

Hi Joseph,

Yes, just send SIGQUIT to yourself anywhere inside the application
dispatch and it'll defer the exit until your application is done
processing.

You should be able to just make it middleware like this:

  # name inspired by the "shotgun" gem
  class Unicorn::Shotgun < Struct.new(:app)
    def call(env)
      Process.kill(:QUIT, 0)
      app.call(env)
    end
  end

-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: workers created when request comes in?
       [not found]   ` <73096a160912152148l4eea211eq972fcea3ebdf9112@mail.gmail.com>
@ 2009-12-16  6:05     ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2009-12-16  6:05 UTC (permalink / raw)
  To: Joseph McDonald; +Cc: mongrel-unicorn

Joseph McDonald <superjoe@gmail.com> wrote:
> On Tue, Dec 15, 2009 at 6:37 PM, Eric Wong <normalperson@yhbt.net> wrote:
> 
> > Yes, just send SIGQUIT to yourself anywhere inside the application
> > dispatch and it'll defer the exit until your application is done
> > processing.
> >
> > You should be able to just make it middleware like this:
> >
> >  # name inspired by the "shotgun" gem
> >  class Unicorn::Shotgun < Struct.new(:app)
> >    def call(env)
> >      Process.kill(:QUIT, 0)
                             ^-- Oops, that should be a $$, not 0
> >      app.call(env)
> >    end
> >  end
> 
> Thanks Eric,
> I added that middleware, but now unicorn exits after servicing one
> request.  I'd like unicorn to keep running and fork off a new child if
> a new request comes in.  Is that possible?

Yeah, just change the 0 to a $$ there, brain fart :x

With that middleware, it should prefork a worker, but then kill it
after every request (and a new one will be preforked).

-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-16  6:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-16  1:37 workers created when request comes in? Joseph McDonald
2009-12-16  2:37 ` Eric Wong
     [not found]   ` <73096a160912152148l4eea211eq972fcea3ebdf9112@mail.gmail.com>
2009-12-16  6:05     ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).