From 667d97d300640e455929d3ecfda54f50bef960e6 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 22 Sep 2022 05:06:49 +0400 Subject: [PATCH] Add simple healthcheck --- client/CServerHandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index e0193efdc..dd3d0ebbc 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -161,6 +161,18 @@ void CServerHandler::startLocalServerAndConnect() threadRunLocalServer->join(); th->update(); + + try + { + CConnection testConnection(settings["server"]["server"].String(), getDefaultPort(), NAME, uuid); + logNetwork->error("Port is busy, kill other vcmiserver processes"); + return; + } + catch(...) + { + //no connection means that port is not busy and we can start local server + } + #ifdef VCMI_ANDROID { CAndroidVMHelper envHelper;