Explorar o código

Add simple healthcheck

nordsoft %!s(int64=3) %!d(string=hai) anos
pai
achega
667d97d300
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      client/CServerHandler.cpp

+ 12 - 0
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;