WEBrick::Daemon and WEBrick


#1

Is it possible to use the WEBrick::Daemon with WEBrick::AbstractServlet.
Here is what i’m running for the basic servlet:

dir = Dir::pwd
server = WEBrick::HTTPServer.new(
:Port => port,
:DocumentRoot => dir
end

server.mount “/gateway”, RUBYAMF::WEBrickServlet
trap “INT” do server.shutdown end
server.start

I’ve seen an example saying you have to subclass the HTTPServer and just
run the WEBrick::Daemon.start when initializing. But can this be done
with servlets?

Thanks.


#2

On Mar 9, 2007, at 14:08, Aaron S. wrote:

server.mount “/gateway”, RUBYAMF::WEBrickServlet
trap “INT” do server.shutdown end
server.start

I’ve seen an example saying you have to subclass the HTTPServer and
just
run the WEBrick::Daemon.start when initializing. But can this be done
with servlets?

Servlets run in a server, so daemonize after you’ve started the
HTTPServer and mounted your servlets.


#3

Eric H. wrote:

On Mar 9, 2007, at 14:08, Aaron S. wrote:

server.mount “/gateway”, RUBYAMF::WEBrickServlet
trap “INT” do server.shutdown end
server.start

I’ve seen an example saying you have to subclass the HTTPServer and
just
run the WEBrick::Daemon.start when initializing. But can this be done
with servlets?

Servlets run in a server, so daemonize after you’ve started the
HTTPServer and mounted your servlets.

I figured it out actually:

server = WEBrick::HTTPServer.new(
:Port => OPTIONS[:port],
:DocumentRoot => OPTIONS[:working_dir],
:ServerType => OPTIONS[:server_type],
:BindAddress => OPTIONS[:ip]
)

server type is either WEBrick::Daemon of WEBrick::SimpleServer