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.



26
27
28
29
30
31
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
# File 'lib/puma/cli.rb', line 26

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 |c|
        c.rackup file
      end
    end
  rescue UnsupportedOption
    exit 1
  end

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

    if @control_url
      c.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.



68
69
70
# File 'lib/puma/cli.rb', line 68

def launcher
  @launcher
end

Instance Method Details

#runObject

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



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

def run
  @launcher.run
end