lib/mb/rest_gateway.rb in motherbrain-1.3.0 vs lib/mb/rest_gateway.rb in motherbrain-1.4.0

- old
+ new

@@ -27,11 +27,11 @@ end end include MB::Logging - DEFAULT_PORT = ENV["PORT"].to_i || 26100 + DEFAULT_PORT = ENV["PORT"] ? ENV["PORT"].to_i : 26100 DEFAULT_OPTIONS = { host: '0.0.0.0', port: DEFAULT_PORT, quiet: false @@ -57,10 +57,15 @@ # reel-rack uses Rack standard capitalizations in > 0.0.2 options[:Host] = options[:host] options[:Port] = options[:port] log.info { "REST Gateway listening on #{options[:host]}:#{options[:port]}" } - super(app, options) + + begin + super(app, options) + rescue Errno::EADDRINUSE + log.fatal { "Port #{options[:port]} is already in use. Unable to start rest gateway." } + end end private def finalize_callback