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:
parent
98db4672cf
commit
376bc15cee
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user