Class: Siru::Server
- Inherits:
-
Object
- Object
- Siru::Server
- Defined in:
- lib/siru/server.rb
Instance Method Summary collapse
-
#initialize(site, options = {}) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(site, options = {}) ⇒ Server
Returns a new instance of Server.
3 4 5 6 7 8 9 |
# File 'lib/siru/server.rb', line 3 def initialize(site, = {}) @site = site = @port = [:port] || 3000 @watch = [:watch] || false @output_dir = 'public' end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/siru/server.rb', line 11 def start puts "Starting Siru server on port #{@port}..." # Build the site initially builder = Builder.new(@site, ) builder.build # Set up file watching if enabled setup_watcher if @watch # Start the web server server = WEBrick::HTTPServer.new( Port: @port, DocumentRoot: @output_dir, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [] ) trap('INT') { server.shutdown } puts "Server running at http://localhost:#{@port}/" puts "Press Ctrl+C to stop" server.start end |