diff --git a/lib/puma/control_cli.rb b/lib/puma/control_cli.rb index 4a2bdc22..ec98eb38 100644 --- a/lib/puma/control_cli.rb +++ b/lib/puma/control_cli.rb @@ -11,9 +11,12 @@ require 'socket' module Puma class ControlCLI - def initialize(argv, stdout=STDOUT) + def initialize(argv, stdout=STDOUT, stderr=STDERR) @argv = argv @stdout = stdout + @stderr = stderr + @path = nil + @config = nil end def setup_options @@ -44,10 +47,12 @@ module Puma def run setup_options - @parser.parse! @argv + @parser.order!(@argv) { |a| @parser.terminate a } - @state = YAML.load File.read(@path) - @config = @state['config'] + if @path + @state = YAML.load File.read(@path) + @config = @state['config'] + end cmd = @argv.shift @@ -84,6 +89,13 @@ module Puma @stdout.puts "#{@state['pid']}" end + def command_start + require 'puma/cli' + + cli = Puma::CLI.new @argv, @stdout, @stderr + cli.run + end + def command_stop sock = connect body = request sock, "/stop"