mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-07 03:16:55 +08:00
feat: add detached flag to run in foreground with detached stdin (#5592)
* feat: add detached flag to run in foreground with detached stdin * adjust contributors * fix code style * ref: move detached cin check to handleinput * Update CONTRIBUTORS
This commit is contained in:
parent
54269d78b2
commit
3c1cc4a513
@ -90,6 +90,7 @@ Spongecade (Updated wiki links)
|
||||
steve-nzr
|
||||
structinf (xdot)
|
||||
sweetgiorni
|
||||
SuperEwald
|
||||
Sxw1212
|
||||
Taugeshtu
|
||||
TheHyper45
|
||||
|
@ -212,6 +212,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
|
||||
m_StartTime = std::chrono::steady_clock::now();
|
||||
|
||||
HandleInput();
|
||||
|
||||
s_StopEvent.Wait();
|
||||
|
||||
// Stop the server:
|
||||
@ -998,7 +999,7 @@ AStringVector cRoot::GetPlayerTabCompletionMultiWorld(const AString & a_Text)
|
||||
|
||||
void cRoot::HandleInput()
|
||||
{
|
||||
if (g_RunAsService)
|
||||
if (g_RunAsService || g_DetachedStdin)
|
||||
{
|
||||
// Ignore input when running as a service, cin was never opened in that case:
|
||||
return;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "OSSupport/MiniDumpWriter.h"
|
||||
#include "OSSupport/SleepResolutionBooster.h"
|
||||
#include "OSSupport/StartAsService.h"
|
||||
#include <tclap/SwitchArg.h>
|
||||
|
||||
|
||||
|
||||
@ -22,6 +23,8 @@ bool g_ShouldLogCommIn;
|
||||
bool g_ShouldLogCommOut;
|
||||
bool g_RunAsService;
|
||||
|
||||
bool g_DetachedStdin;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -44,9 +47,14 @@ static void ParseArguments(int argc, char ** argv, cMemorySettingsRepository & a
|
||||
TCLAP::SwitchArg noBufArg ("", "no-output-buffering", "Disable output buffering", cmd);
|
||||
TCLAP::SwitchArg noFileLogArg ("", "no-log-file", "Disable logging to file", cmd);
|
||||
TCLAP::SwitchArg runAsServiceArg ("d", "service", "Run as a service on Windows, or daemon on UNIX like systems", cmd);
|
||||
TCLAP::SwitchArg runDetached ("", "detached", "Run with detached stdin (useful for container/docker)", cmd);
|
||||
cmd.parse(argc, argv);
|
||||
|
||||
// Copy the parsed args' values into a settings repository:
|
||||
if (runDetached.getValue())
|
||||
{
|
||||
g_DetachedStdin = true;
|
||||
}
|
||||
if (confArg.isSet())
|
||||
{
|
||||
AString conf_file = confArg.getValue();
|
||||
|
@ -8,3 +8,6 @@ extern bool g_ShouldLogCommOut;
|
||||
|
||||
/** If set to true, binary will attempt to run as a service. */
|
||||
extern bool g_RunAsService;
|
||||
|
||||
/** If set to true, binary runs in foreground without cstding handles */
|
||||
extern bool g_DetachedStdin;
|
||||
|
Loading…
Reference in New Issue
Block a user