mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 01:37:04 +00:00
[6830] Implement custom exit codes on server shutdown/restart
Added the possibility to use custom process return values instead of hardcoded 0 (shutdown) or 2 (restart) to allow using them for various custom external features / better handling. This can be used through 4 commands in ".server" family: - shutdown - restart - idleshutdown - idlerestart Those have from now on 2 arguments, where the second (return value) is optional: .server <command> <time> [return_value] If return_value is not specified, default value (0 or 2) is used. Signed-off-by: freghar <compmancz@gmail.com> Set restart exist code for SIGINT singnal case. Some code simplifications for original patch. Related code cleanups. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
3d72b06fcd
commit
528a9d830a
8 changed files with 149 additions and 49 deletions
|
|
@ -165,7 +165,7 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args)
|
|||
bool ChatHandler::HandleServerExitCommand(const char* args)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_EXIT);
|
||||
World::m_stopEvent = true;
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -306,14 +306,14 @@ void CliRunnable::run()
|
|||
printf("mangos>");
|
||||
|
||||
///- As long as the World is running (no World::m_stopEvent), get the command line and handle it
|
||||
while (!World::m_stopEvent)
|
||||
while (!World::IsStopped())
|
||||
{
|
||||
fflush(stdout);
|
||||
#ifdef linux
|
||||
while (!kb_hit_return() && !World::m_stopEvent)
|
||||
while (!kb_hit_return() && !World::IsStopped())
|
||||
// With this, we limit CLI to 10commands/second
|
||||
usleep(100);
|
||||
if (World::m_stopEvent)
|
||||
if (World::IsStopped())
|
||||
break;
|
||||
#endif
|
||||
char *command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
|
||||
|
|
@ -344,7 +344,7 @@ void CliRunnable::run()
|
|||
}
|
||||
else if (feof(stdin))
|
||||
{
|
||||
World::m_stopEvent = true;
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue