mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-06-18 23:20:53 +00:00
Application: Perform hard-shutdown after 3 Ctrl+C's
This commit is contained in:
+9
-2
@@ -22,10 +22,17 @@ void Application::RegisterShutdownHandler(const TShutdownHandler& Handler) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool AlreadyShuttingDown = false;
|
|
||||||
void Application::GracefullyShutdown() {
|
void Application::GracefullyShutdown() {
|
||||||
|
static bool AlreadyShuttingDown = false;
|
||||||
|
static uint8_t ShutdownAttempts = 0;
|
||||||
if (AlreadyShuttingDown) {
|
if (AlreadyShuttingDown) {
|
||||||
info("already shutting down");
|
++ShutdownAttempts;
|
||||||
|
// hard shutdown at 2 additional tries
|
||||||
|
if (ShutdownAttempts == 2) {
|
||||||
|
info("hard shutdown forced by multiple shutdown requests");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
info("already shutting down!");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
AlreadyShuttingDown = true;
|
AlreadyShuttingDown = true;
|
||||||
|
|||||||
+1
-2
@@ -3,6 +3,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "CustomAssert.h"
|
#include "CustomAssert.h"
|
||||||
#include "Http.h"
|
#include "Http.h"
|
||||||
|
#include "SignalHandling.h"
|
||||||
#include "TConfig.h"
|
#include "TConfig.h"
|
||||||
#include "THeartbeatThread.h"
|
#include "THeartbeatThread.h"
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
@@ -10,7 +11,6 @@
|
|||||||
#include "TPPSMonitor.h"
|
#include "TPPSMonitor.h"
|
||||||
#include "TResourceManager.h"
|
#include "TResourceManager.h"
|
||||||
#include "TServer.h"
|
#include "TServer.h"
|
||||||
#include "SignalHandling.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -63,4 +63,3 @@ int main(int argc, char** argv) try {
|
|||||||
error(e.what());
|
error(e.what());
|
||||||
Sentry.LogException(e, _file_basename, _line);
|
Sentry.LogException(e, _file_basename, _line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user