Skip to content

Commit

Permalink
start http server
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorerlingsson committed Oct 8, 2024
1 parent f07a989 commit 5b2d6ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/amqproxy/cli.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "./version"
require "./server"
require "./http_server"
require "option_parser"
require "uri"
require "ini"
Expand All @@ -8,6 +9,7 @@ require "log"
class AMQProxy::CLI
@listen_address = ENV["LISTEN_ADDRESS"]? || "localhost"
@listen_port = ENV["LISTEN_PORT"]? || 5673
@http_port = ENV["HTTP_PORT"]? || 15673
@log_level : Log::Severity = Log::Severity::Info
@idle_connection_timeout : Int32 = ENV.fetch("IDLE_CONNECTION_TIMEOUT", "5").to_i
@term_timeout = -1
Expand Down Expand Up @@ -49,6 +51,7 @@ class AMQProxy::CLI
@listen_address = v
end
parser.on("-p PORT", "--port=PORT", "Port to listen on (default: 5673)") { |v| @listen_port = v.to_i }
parser.on("-b PORT", "--http-port=PORT", "HTTP Port to listen on (default: 15673)") { |v| @http_port = v.to_i }
parser.on("-t IDLE_CONNECTION_TIMEOUT", "--idle-connection-timeout=SECONDS", "Maxiumum time in seconds an unused pooled connection stays open (default 5s)") do |v|
@idle_connection_timeout = v.to_i
end
Expand Down Expand Up @@ -104,6 +107,7 @@ class AMQProxy::CLI
Signal::INT.trap &shutdown
Signal::TERM.trap &shutdown

AMQProxy::HTTPServer.new(server, @listen_address, @http_port.to_i)
server.listen(@listen_address, @listen_port.to_i)

# wait until all client connections are closed
Expand Down

0 comments on commit 5b2d6ec

Please sign in to comment.