From: Lloyd Zusman Date: 2004-11-23T08:01:51+09:00 Subject: Re: fast shutdown of webrick Simon Strandgaard 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.org/runit 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.