Sha256: 6ffca7bb0c1de2a1b1a590cb1b54249a6284278f1d76b3bced78610f6a1ca68e

Contents?: true

Size: 1.63 KB

Versions: 7

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Mihari
  module Commands
    #
    # Web sub-commands
    #
    module Web
      class << self
        def 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: "0:5", desc: "min:max threads to use"
            method_option :verbose, type: :boolean, default: true, desc: "Report each request"
            method_option :worker_timeout, type: :numeric, default: 60, desc: "Worker timeout value (in seconds)"
            method_option :hide_config_values, type: :boolean, default: true,
              desc: "Whether to hide config values or not"
            method_option :open, type: :boolean, default: true, desc: "Whether to open the app in browser or not"
            method_option :rack_env, type: :string, default: "production", desc: "Rack environment"
            def web
              Mihari.config.hide_config_values = options["hide_config_values"]
              # set rack env as production
              ENV["RACK_ENV"] ||= options["rack_env"]
              Mihari::Web::App.run!(
                port: options["port"],
                host: options["host"],
                threads: options["threads"],
                verbose: options["verbose"],
                worker_timeout: options["worker_timeout"],
                open: options["open"]
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/commands/web.rb
mihari-6.2.0 lib/mihari/commands/web.rb
mihari-6.1.0 lib/mihari/commands/web.rb
mihari-6.0.0 lib/mihari/commands/web.rb
mihari-5.7.2 lib/mihari/commands/web.rb
mihari-5.7.1 lib/mihari/commands/web.rb
mihari-5.7.0 lib/mihari/commands/web.rb