Sha256: 0ca5c10545406123c386dc9f4dbff82a667056094729f30eebd66c993bb3029f

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 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", "Start 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 :open, type: :boolean, default: true, desc: "Whether to open the app in browser or not"
            method_option :env, type: :string, default: "production", desc: "Environment"
            def web
              require "mihari/web/application"

              ENV["APP_ENV"] ||= options["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

9 entries across 9 versions & 1 rubygems

Version Path
mihari-7.1.2 lib/mihari/commands/web.rb
mihari-7.1.1 lib/mihari/commands/web.rb
mihari-7.1.0 lib/mihari/commands/web.rb
mihari-7.0.5 lib/mihari/commands/web.rb
mihari-7.0.4 lib/mihari/commands/web.rb
mihari-7.0.3 lib/mihari/commands/web.rb
mihari-7.0.2 lib/mihari/commands/web.rb
mihari-7.0.1 lib/mihari/commands/web.rb
mihari-7.0.0 lib/mihari/commands/web.rb