Class: Adsf::Server
- Inherits:
-
Object
- Object
- Adsf::Server
- Defined in:
- lib/adsf/server.rb
Constant Summary collapse
- DEFAULT_HANDLER_NAME =
:thin
Instance Method Summary collapse
-
#initialize(root:, live: false, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(root:, live: false, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil) ⇒ Server
Returns a new instance of Server.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/adsf/server.rb', line 7 def initialize(root:, live: false, index_filenames: ['index.html'], host: '127.0.0.1', port: 3000, handler: nil) @root = root @live = live @index_filenames = index_filenames @host = host @port = port @handler = handler @q = SizedQueue.new(1) end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/adsf/server.rb', line 18 def run handler = build_handler app = build_app(root: @root, index_filenames: @index_filenames) start_watcher if @live url = "http://#{@host}:#{@port}/" puts "View the site at #{url}" handler.run(app, Host: @host, Port: @port) do |server| wait_for_stop_async(server) end end |
#stop ⇒ Object
31 32 33 |
# File 'lib/adsf/server.rb', line 31 def stop @q << true end |