WEBRick initialization

  • Thread starter Alexey Verkhovsky
  • Start date
A

Alexey Verkhovsky

I have some WEBRick server that I would like to run as WEBRick::Daemon
(that's where a startup process forks a daemon and exits). The problem
is, there is some initialization code that must be executed _after_ the
fork (it opens a file for writing). Is there any good way to make it
happen (short of overriding WEBRick::Daemon#start method)?

Best regards,
Alexey Verkhovsky
 
G

GOTOU Yuuzou

In message said:
I have some WEBRick server that I would like to run as WEBRick::Daemon
(that's where a startup process forks a daemon and exits). The problem
is, there is some initialization code that must be executed _after_ the
fork (it opens a file for writing). Is there any good way to make it
happen (short of overriding WEBRick::Daemon#start method)?

How about calling WEBrick::Daemon.start directly?

require "webrick"

WEBrick::Daemon.start
httpd = WEBrick::HTTPServer.new:)Port=>10080)
trap:)INT){ httpd.stop }
httpd.mount_proc("/"){|req, res|
res["content-type"] = "text/plain"
res.body = $$.to_s
}
httpd.start
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,478
Latest member
ReginaldVi

Latest Threads

Top