]> Sergey Matveev's repositories - public-inbox.git/blob - examples/cgi-webrick.rb
treewide: run update-copyrights from gnulib for 2019
[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.  For those familiar with Perl web servers,
5 # plackup(1) is recommended for development and public-inbox-httpd(1)
6 # is our production deployment server.
7 require 'webrick'
8 require 'logger'
9 options = {
10   :BindAddress => '127.0.0.1',
11   :Port => 8080,
12   :Logger => Logger.new($stderr),
13   :CGIPathEnv => ENV['PATH'], # need to run 'git' commands
14   :AccessLog => [
15     [ Logger.new($stdout), WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
16   ],
17 }
18 server = WEBrick::HTTPServer.new(options)
19 server.mount("/",
20              WEBrick::HTTPServlet::CGIHandler,
21             "/var/www/cgi-bin/public-inbox.cgi")
22 ['INT', 'TERM'].each do |signal|
23   trap(signal) {exit!(0)}
24 end
25 server.start