-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.rb
More file actions
29 lines (27 loc) · 885 Bytes
/
server.rb
File metadata and controls
29 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'sinatra/base'
require 'webrick'
require_relative 'genkai'
# Reason phrase のあとに空白が入るバグをモンキーパッチする。
module WEBrick
class HTTPResponse
def status_line
"HTTP/#@http_version #@status #@reason_phrase#{CRLF}"
end
end
end
log_file = File.open('error_log', 'a+')
log = WEBrick::Log.new log_file
log_file2 = File.open('access_log', 'a+')
access_log = [
[log_file2, WEBrick::AccessLog::COMBINED_LOG_FORMAT],
]
Process.setproctitle("genkai")
app = Genkai::Application.new
srv = WEBrick::HTTPServer.new({ :DocumentRoot => './',
:BindAddress => '0.0.0.0',
:Port => 10000,
:Logger => log,
:AccessLog => access_log})
srv.mount('/', Rack::Handler::WEBrick, app)
trap("INT"){ srv.shutdown }
srv.start