[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

fast shutdown of webrick

Simon Strandgaard

11/22/2004 6:45:00 PM

On my box trap(:INT){ s.shutdown } takes some time to complete.
Im wondering how one can shut it down fast and safe.

Is this an ok way to shut it down?

trap(:INT) do
fork{ s.shutdown }
exit!
end


btw: Any clues how to quickly restart webrick ?

--
Simon Strandgaard


4 Answers

David Heinemeier Hansson

11/22/2004 10:49:00 PM

0

> Is this an ok way to shut it down?
>
> btw: Any clues how to quickly restart webrick ?

I'm pretty interested in the answer to both of these questions :). The
WEBrick servlet will be the preferred development platform from the
next version of Rails (with really nice integrated breakpoint support
and more!), so we're looking to make the experience as nice as
possible.

(Yes, you can and should still deploy production apps on Apache)
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://macro... -- TextMate: Code and markup editor (OS X)
http://www.loudthi... -- Broadcasting Brain



Jamis Buck

11/22/2004 11:00:00 PM

0

David Heinemeier Hansson wrote:
>> Is this an ok way to shut it down?
>>
>> btw: Any clues how to quickly restart webrick ?
>
>
> I'm pretty interested in the answer to both of these questions :). The
> WEBrick servlet will be the preferred development platform from the next
> version of Rails (with really nice integrated breakpoint support and
> more!), so we're looking to make the experience as nice as possible.
>
> (Yes, you can and should still deploy production apps on Apache)

I haven't done any exhaustive research into this topic, but this is what
I've observed, along with my speculative conclusions:

1) When the last request to WEBrick results in an exception, I can
shutdown WEBrick and it terminates quite snappily.

2) When the last request to WEBrick is successful (with no raised
exception), WEBrick can take up to a minute to actually terminate.

I *suspect* that this has something to do with the browser keeping the
connection to WEBrick alive. Perhaps WEBrick can't shut down as long as
there is an active connection, and it has to wait for that connection to
time out? Can anyone comment on how feasible this might be?

- Jamis

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck...


Lloyd Zusman

11/22/2004 11:02:00 PM

0

Simon Strandgaard <neoneye@adslhome.dk> writes:

> On my box trap(:INT){ s.shutdown } takes some time to complete.
> Im wondering how one can shut it down fast and safe.
>
> Is this an ok way to shut it down?
>
> trap(:INT) do
> fork{ s.shutdown }
> exit!
> end

I'm not sure why you would need the fork.

I just do this, and it dies very quickly.

%w[ SIGHUP SIGINT SIGQUIT SIGTERM ].each {
|sig|
trap(sig) {
# I forget whether or not the reference to the server
# needs to be stored in a global in order for it to
# be seen here. I do it anyway, just in case.
$s.shutdown
}
}


> btw: Any clues how to quickly restart webrick ?

I use the 'runit' system to manage a lot of my daemons, including the
one I use for webrick. Check it out here:

http://smarden...

I can completely restart my webrick daemon in about 5-10 seconds using
the 'runsvctrl' program that's part of this system.

I trap SIGHUP and SIGTERM above in addition to SIGINT because I can
easily send these signals to the daemon via 'runsvctrl'. I also throw
SIGQUIT in there because some systems switch the meaning of SIGQUIT and
SIGINT, and I always forget which ones do which.


--
Lloyd Zusman
ljz@asfast.com
God bless you.



GOTOU Yuuzou

11/23/2004 12:19:00 AM

0