Module: Mihari::Commands::Web

Included in:
Mihari::CLI::Main
Defined in:
lib/mihari/commands/web.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mihari/commands/web.rb', line 6

def self.included(thor)
  thor.class_eval do
    desc "web", "Launch the web app"
    method_option :port, type: :numeric, default: 9292, desc: "Hostname to listen on"
    method_option :host, type: :string, default: "localhost", desc: "Port to listen on"
    method_option :threads, type: :string, default: "1:1", desc: "min:max threads to use"
    method_option :verbose, type: :boolean, default: true, desc: "Report each request"
    def web
      port = options["port"]
      host = options["host"]
      threads = options["threads"]
      verbose = options["verbose"]

      # set rack env as production
      ENV["RACK_ENV"] ||= "production"

      Mihari::App.run!(port: port, host: host, threads: threads, verbose: verbose)
    end
  end
end