Object
# File lib/puma/control_cli.rb, line 98 def command_halt sock = connect body = request sock, "/halt" if body != '{ "status": "ok" }' raise "Invalid response: '#{body}'" else @stdout.puts "Requested halt from server" end end
# File lib/puma/control_cli.rb, line 83 def command_pid @stdout.puts "#{@state['pid']}" end
# File lib/puma/control_cli.rb, line 109 def command_restart sock = connect body = request sock, "/restart" if body != '{ "status": "ok" }' raise "Invalid response: '#{body}'" else @stdout.puts "Requested restart from server" end end
# File lib/puma/control_cli.rb, line 120 def command_stats sock = connect body = request sock, "/stats" @stdout.puts body end
# File lib/puma/control_cli.rb, line 87 def command_stop sock = connect body = request sock, "/stop" if body != '{ "status": "ok" }' raise "Invalid response: '#{body}'" else @stdout.puts "Requested stop from server" end end
# File lib/puma/control_cli.rb, line 27 def connect if str = @config.options[:control_url] uri = URI.parse str case uri.scheme when "tcp" return TCPSocket.new uri.host, uri.port when "unix" path = "#{uri.host}#{uri.path}" return UNIXSocket.new path else raise "Invalid URI: #{str}" end end raise "No status address configured" end
# File lib/puma/control_cli.rb, line 63 def request(sock, url) token = @config.options[:control_auth_token] if token url = "#{url}?token=#{token}" end sock << "GET #{url} HTTP/1.0\r\n\r\n" rep = sock.read.split("\r\n") m = %HTTP/1.\d (\d+)!.match(rep.first) if m[1] == "403" raise "Unauthorized access to server (wrong auth token)" elsif m[1] != "200" raise "Bad response code from server: #{m[1]}" end return rep.last end
Generated with the Darkfish Rdoc Generator 2.