diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-15 14:13:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-15 14:13:38 +0100 |
commit | e390ccd415cc6ecb3187f559eb95abf0738d8745 (patch) | |
tree | 7085a55492bbcca9c4eea0f9d009c9c988db9472 | |
parent | f565579fd51cb98d9a926b76734accc134868266 (diff) | |
parent | 7f086605b5d23f42651dfbf430b3c25f14799c9f (diff) |
Merge pull request #11318 from vespa-engine/jvenstad/handle-port-listen-excpetion-in-config-sentinel
Jvenstad/handle port listen excpetion in config sentinel
-rw-r--r-- | configd/src/apps/sentinel/config-handler.cpp | 6 | ||||
-rw-r--r-- | configd/src/apps/sentinel/sentinel.cpp | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp index a73a5f01f33..7b68e6c8150 100644 --- a/configd/src/apps/sentinel/config-handler.cpp +++ b/configd/src/apps/sentinel/config-handler.cpp @@ -5,6 +5,8 @@ #include <vespa/vespalib/net/simple_metric_snapshot.h> #include <vespa/vespalib/net/socket_address.h> +#include <vespa/vespalib/util/exceptions.h> +#include <string> #include <fcntl.h> #include <sys/wait.h> @@ -24,9 +26,7 @@ ConfigHandler::configure_port(int port) } } if (port <= 0 || port > 65535) { - LOG(error, "Fatal: bad port %d, expected range [1,65535]", port); - EV_STOPPING("config-sentinel", "bad port"); - exit(EXIT_FAILURE); + throw vespalib::FatalException("Bad port " + std::to_string(port) + ", expected range [1, 65535]", VESPA_STRLOC); } if (port != _boundPort) { LOG(debug, "Config-sentinel accepts connections on port %d", port); diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp index 023b96ce96c..126c59d42f3 100644 --- a/configd/src/apps/sentinel/sentinel.cpp +++ b/configd/src/apps/sentinel/sentinel.cpp @@ -5,6 +5,7 @@ #include <unistd.h> #include <sys/time.h> #include <vespa/vespalib/util/signalhandler.h> +#include <vespa/vespalib/util/exceptions.h> #include <vespa/defaults.h> #include "config-handler.h" @@ -85,8 +86,15 @@ main(int argc, char **argv) vespalib::SignalHandler::CHLD.clear(); handler.doWork(); // Check for child procs & commands } catch (InvalidConfigException& ex) { - LOG(warning, "Configuration problem: (ignoring): %s", - ex.what()); + LOG(warning, "Configuration problem: (ignoring): %s", ex.what()); + } catch (vespalib::PortListenException& ex) { + LOG(error, "Fatal: %s", ex.getMessage().c_str()); + EV_STOPPING("config-sentinel", ex.what()); + exit(EXIT_FAILURE); + } catch (vespalib::FatalException& ex) { + LOG(error, "Fatal: %s", ex.getMessage().c_str()); + EV_STOPPING("config-sentinel", ex.what()); + exit(EXIT_FAILURE); } if (vespalib::SignalHandler::CHLD.check()) { continue; |