]> Sergey Matveev's repositories - public-inbox.git/blob - examples/cgi-webrick.rb
examples: make web configs consistent and add README
[public-inbox.git] / examples / cgi-webrick.rb
1 #!/usr/bin/env ruby
2 # Sample configuration using WEBrick, mainly intended dev/testing
3 # for folks familiar with Ruby and not various Perl webserver
4 # deployment options.
5 require 'webrick'
6 require 'logger'
7 options = {
8   :BindAddress => '127.0.0.1',
9   :Port => 8080,
10   :Logger => Logger.new($stderr),
11   :AccessLog => [
12     [ Logger.new($stdout), WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
13   ],
14 }
15 server = WEBrick::HTTPServer.new(options)
16 server.mount("/",
17              WEBrick::HTTPServlet::CGIHandler,
18             "/var/www/cgi-bin/public-inbox.cgi")
19 ['INT', 'TERM'].each do |signal|
20   trap(signal) {exit!(0)}
21 end
22 server.start