Module: Miteru::Commands::Web

Included in:
Miteru::CLI::App
Defined in:
lib/miteru/commands/web.rb

Overview

Web sub-commands

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/miteru/commands/web.rb', line 10

def included(thor)
  thor.class_eval do
    desc "web", "Start the web app"
    method_option :port, type: :numeric, default: 9292, desc: "Port to listen on"
    method_option :host, type: :string, default: "localhost", desc: "Hostname to listen on"
    method_option :threads, type: :string, default: "0:3", desc: "min:max threads to use"
    method_option :verbose, type: :boolean, default: false, desc: "Don't report each request"
    method_option :worker_timeout, type: :numeric, default: 60, desc: "Worker timeout value (in seconds)"
    method_option :env, type: :string, default: "production", desc: "Environment"
    def web
      require "miteru/web/application"

      ENV["APP_ENV"] ||= options["env"]

      Miteru::Web::App.run!(
        port: options["port"],
        host: options["host"],
        threads: options["threads"],
        verbose: options["verbose"],
        worker_timeout: options["worker_timeout"]
      )
    end
  end
end