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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



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
67
# File 'lib/puma/cli.rb', line 27

def initialize(argv, log_writer = LogWriter.stdio, events = Events.new)
  @debug = false
  @argv = argv.dup
  @log_writer = log_writer
  @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, :log_writer => @log_writer, :events => @events, :argv => argv)
end

Instance Attribute Details

#launcherObject (readonly)

Returns the value of attribute launcher.



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

def launcher
  @launcher
end

Instance Method Details

#runObject

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



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

def run
  @launcher.run
end