#!/usr/local/bin/ruby # sample of HTTP server spawned from inetd. log = open("/var/log/webrick/httpd.log", "a") STDERR.reopen(log) # do not send stderr to client. require 'webrick' require 'getopts' getopts nil, 'r:' sock = TCPSocket.for_fd(0, "w+") # create TCPSocket from fd. port = sock.addr[1] s=WEBrick::HTTPServer.new( :DoNotListen => true, :Port => port, :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG), :DocumentRoot => $OPT_r || "/usr/local/webrick/htdocs" ) s.run(sock)