Class: Puma::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/cli.rb

Overview

Handles invoke a Puma::Server in a command line style.

Constant Summary collapse

KEYS_NOT_TO_PERSIST_IN_STATE =
Launcher::KEYS_NOT_TO_PERSIST_IN_STATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, events = Events.stdio) ⇒ CLI

Create a new CLI object using argv as the command line arguments.

stdout and stderr can be set to IO-like objects which this object will report status on.


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/puma/cli.rb', line 32

def initialize(argv, events=Events.stdio)
  @debug = false
  @argv = argv.dup

  @events = events

  @conf = nil

  @stdout = nil
  @stderr = nil
  @append = false

  @control_url = nil
  @control_options = {}

  setup_options

  begin
    @parser.parse! @argv

    if file = @argv.shift
      @conf.configure do |user_config, file_config|
        file_config.rackup file
      end
    end
  rescue UnsupportedOption
    exit 1
  end

  @conf.configure do |user_config, file_config|
    if @stdout || @stderr
      user_config.stdout_redirect @stdout, @stderr, @append
    end

    if @control_url
      user_config.activate_control_app @control_url, @control_options
    end
  end

  @launcher = Puma::Launcher.new(@conf, :events => @events, :argv => argv)
end

Instance Attribute Details

#launcherObject (readonly)

Returns the value of attribute launcher


74
75
76
# File 'lib/puma/cli.rb', line 74

def launcher
  @launcher
end

Instance Method Details

#runObject

Parse the options, load the rackup, start the server and wait for it to finish.


79
80
81
# File 'lib/puma/cli.rb', line 79

def run
  @launcher.run
end