Class: SimplerDB::Server
- Inherits:
-
Object
- Object
- SimplerDB::Server
- Defined in:
- lib/simplerdb/server.rb
Instance Method Summary collapse
-
#initialize(port = nil) ⇒ Server
constructor
Create the server running on the given port.
-
#shutdown ⇒ Object
Shut down the server.
-
#start ⇒ Object
Run the server on the configured port.
Constructor Details
#initialize(port = nil) ⇒ Server
Create the server running on the given port
10 11 12 |
# File 'lib/simplerdb/server.rb', line 10 def initialize(port = nil) @port = port || 8087 end |
Instance Method Details
#shutdown ⇒ Object
Shut down the server
28 29 30 |
# File 'lib/simplerdb/server.rb', line 28 def shutdown @server.shutdown end |
#start ⇒ Object
Run the server on the configured port.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/simplerdb/server.rb', line 15 def start config = { :Port => @port } @server = WEBrick::HTTPServer.new(config) @server.mount("/", SimplerDB::RESTServlet) ['INT', 'TERM'].each do |signal| trap(signal) { @server.shutdown } end @server.start end |