lib/munge/cli/commands/view.rb in munge-0.10.0 vs lib/munge/cli/commands/view.rb in munge-0.11.0
- old
+ new
@@ -26,21 +26,32 @@
module Munge
module Cli
module Commands
class View
- def initialize(bootloader, host:, port:)
+ def initialize(bootloader, host:, port:, build_root: nil)
config = bootloader.config
+ @host = host
+ @port = port
+ root = File.expand_path(build_root || config[:output], bootloader.root_path)
- app =
+ @app =
Rack::Builder.new do
use Rack::ShowExceptions
use Rack::Head
- use Adsf::Rack::IndexFileFinder, root: config[:output]
- run Rack::File.new(config[:output])
+ use Adsf::Rack::IndexFileFinder, root: root
+ run Rack::File.new(root)
end
+ end
- Rack::Handler::WEBrick.run(app, Host: host, Port: port)
+ def call
+ Signal.trap("INT") do
+ # Prints a newline after the terminal prints `^C`
+ puts
+ Rack::Handler::WEBrick.shutdown
+ end
+
+ Rack::Handler::WEBrick.run(@app, Host: @host, Port: @port)
end
end
end
end
end