ソースを参照

Add simple healthcheck

nordsoft 3 年 前
コミット
667d97d300
1 ファイル変更12 行追加0 行削除
  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;