diff options
| author | Dan Engelbrecht <[email protected]> | 2024-08-22 10:37:08 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-22 10:37:08 +0200 |
| commit | 9ce07726a982259439bb50f40954c0831fe5b916 (patch) | |
| tree | 6a21876ea5b951a7d90a2beb67b3a20094fbc433 /src/zenserver/zenserver.cpp | |
| parent | remove bad assert when payload is memcached but metadata is not set (#130) (diff) | |
| download | zen-9ce07726a982259439bb50f40954c0831fe5b916.tar.xz zen-9ce07726a982259439bb50f40954c0831fe5b916.zip | |
if a zenserver is already using our named mutex - exit with error code instead of reporting error to Sentry (#132)
Diffstat (limited to 'src/zenserver/zenserver.cpp')
| -rw-r--r-- | src/zenserver/zenserver.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index 62c9227fe..dcfef7530 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -117,6 +117,14 @@ ZenServer::OnReady() int ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) { + const std::string MutexName = fmt::format("zen_{}", ServerOptions.BasePort); + + if (NamedMutex::Exists(MutexName)) + { + ZEN_WARN("Mutex '{}' already exists - is another instance already running?", MutexName); + return -1; + } + m_UseSentry = ServerOptions.NoSentry == false; m_ServerEntry = ServerEntry; m_DebugOptionForcedCrash = ServerOptions.ShouldCrash; @@ -132,7 +140,7 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen if (!OwnerProcess.IsValid()) { - ZEN_WARN("Unable to initialize process handle for specified parent pid #{}", ParentPid); + ZEN_WARN("Unable to initialize process handle for specified parent pid #{}. Reason: '{}'", ParentPid, Ec.message()); // If the pid is not reachable should we just shut down immediately? the intended owner process // could have been killed or somehow crashed already @@ -147,12 +155,6 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen // Initialize/check mutex based on base port - std::string MutexName = fmt::format("zen_{}", ServerOptions.BasePort); - - if (NamedMutex::Exists(MutexName)) - { - throw std::runtime_error(fmt::format("Mutex '{}' already exists - is another instance already running?", MutexName).c_str()); - } if (m_ServerMutex.Create(MutexName) == false) { ThrowLastError(fmt::format("Failed to create mutex '{}'", MutexName).c_str()); @@ -171,6 +173,7 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen m_Http = CreateHttpServer(ServerOptions.HttpServerConfig); int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort, ServerOptions.DataDir); + ZEN_ASSERT(EffectiveBasePort > 0); // Setup authentication manager { |