2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-26 21:41:06 +03:00

Graceful shutdown on sigterm (#776)

* Add players kick on SIGINT \ SIGTERM
* Add SIGINT & SIGTERM handling linux console
* change shutdown method
This commit is contained in:
Sergey Shorokhov 2020-08-19 13:14:22 +03:00 committed by GitHub
parent 98db4672cf
commit 376bc15cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -314,8 +314,21 @@ char* BuildCmdLine(int argc, char **argv)
return linuxCmdline;
}
static void ConsoleCtrlHandler(int signal)
{
if (signal == SIGINT || signal == SIGTERM)
{
g_bAppHasBeenTerminated = true;
}
}
bool Sys_SetupConsole()
{
struct sigaction action;
action.sa_handler = ConsoleCtrlHandler;
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
return true;
}
@ -327,7 +340,6 @@ int main(int argc, char *argv[])
{
Q_snprintf(g_szEXEName, sizeof(g_szEXEName), "%s", argv[0]);
char* cmdline = BuildCmdLine(argc, argv);
StartServer(cmdline);
return 0;
return StartServer(cmdline) == LAUNCHER_OK ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -1212,7 +1212,12 @@ void Host_Shutdown(void)
if (host_initialized) // Client-side
Host_WriteConfiguration();
#ifdef REHLDS_FIXES
Host_ShutdownServer(FALSE);
#else
SV_ServerShutdown();
#endif
Voice_Deinit();
host_initialized = FALSE;