Class: TDiary::Server
- Inherits:
-
Object
- Object
- TDiary::Server
- Defined in:
- lib/tdiary/server.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Server
constructor
A new instance of Server.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(opts) ⇒ Server
Returns a new instance of Server.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tdiary/server.rb', line 30 def initialize( opts ) @server = WEBrick::HTTPServer.new( Port: opts[:port], BindAddress: opts[:bind], DocumentRoot: TDiary.root, MimeTypes: tdiary_mime_types, Logger: webrick_logger_to( opts[:logger] ), AccessLog: webrick_access_log_to( opts[:access_log] ), ServerType: opts[:daemon] ? WEBrick::Daemon : nil, CGIInterpreter: WEBrick::HTTPServlet::CGIHandler::Ruby ) @server.logger.level = WEBrick::Log::DEBUG @server.mount("/", WEBrick::HTTPServlet::CGIHandler, TDiary.root + "/index.rb") @server.mount("/index.rb", WEBrick::HTTPServlet::CGIHandler, TDiary.root + '/index.rb') @server.mount("/update.rb", WEBrick::HTTPServlet::CGIHandler, TDiary.root + "/update.rb") @server.mount("/theme", WEBrick::HTTPServlet::FileHandler, TDiary.root + '/theme') @server.mount("/js", WEBrick::HTTPServlet::FileHandler, TDiary.root + '/js') end |
Class Method Details
.run(option) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/tdiary/server.rb', line 16 def run( option ) @@server = new( option ) trap( "INT" ) { @@server.shutdown } trap( "TERM" ) { @@server.shutdown } @@server.start end |
.stop ⇒ Object
25 26 27 |
# File 'lib/tdiary/server.rb', line 25 def stop @@server.shutdown end |
Instance Method Details
#shutdown ⇒ Object
52 53 54 |
# File 'lib/tdiary/server.rb', line 52 def shutdown @server.shutdown end |
#start ⇒ Object
48 49 50 |
# File 'lib/tdiary/server.rb', line 48 def start @server.start end |