aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver')
-rw-r--r--src/zenserver/config.cpp3
-rw-r--r--src/zenserver/config.h1
-rw-r--r--src/zenserver/zenserver.cpp8
-rw-r--r--src/zenserver/zenserver.h1
4 files changed, 13 insertions, 0 deletions
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp
index 3640abfaf..92d6c7f7d 100644
--- a/src/zenserver/config.cpp
+++ b/src/zenserver/config.cpp
@@ -960,6 +960,9 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
"Specify a snapshot of server state to mirror into the persistence root at startup",
cxxopts::value<std::string>(BaseSnapshotDir));
options.add_options()("content-dir", "Frontend content directory", cxxopts::value<std::string>(ContentDir));
+ options.add_options()("powercycle",
+ "Exit immediately after initialization is complete",
+ cxxopts::value<bool>(ServerOptions.IsPowerCycle));
options.add_options()("abslog", "Path to log file", cxxopts::value<std::string>(AbsLogFile));
options.add_options()("config", "Path to Lua config file", cxxopts::value<std::string>(ConfigFile));
options.add_options()("write-config", "Path to output Lua config file", cxxopts::value<std::string>(OutputConfigFile));
diff --git a/src/zenserver/config.h b/src/zenserver/config.h
index c7f6e1e2a..8135bf8f0 100644
--- a/src/zenserver/config.h
+++ b/src/zenserver/config.h
@@ -142,6 +142,7 @@ struct ZenServerOptions
bool UninstallService = false; // Flag used to initiate service uninstall (temporary)
bool IsDebug = false;
bool IsCleanStart = false; // Indicates whether all state should be wiped on startup or not
+ bool IsPowerCycle = false; // When true, the process shuts down immediately after initialization
bool IsTest = false;
bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements
bool ShouldCrash = false; // Option for testing crash handling
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index a50ff1b53..ba9ff4f88 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -117,6 +117,7 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen
m_UseSentry = ServerOptions.NoSentry == false;
m_ServerEntry = ServerEntry;
m_DebugOptionForcedCrash = ServerOptions.ShouldCrash;
+ m_IsPowerCycle = ServerOptions.IsPowerCycle;
const int ParentPid = ServerOptions.OwnerPid;
if (ParentPid)
@@ -591,6 +592,13 @@ ZenServer::Run()
OnReady();
+ if (m_IsPowerCycle)
+ {
+ ZEN_INFO("Power cycle mode enabled -- shutting down");
+
+ RequestExit(0);
+ }
+
m_Http->Run(IsInteractiveMode);
SetNewState(kShuttingDown);
diff --git a/src/zenserver/zenserver.h b/src/zenserver/zenserver.h
index 7da536708..becc3437d 100644
--- a/src/zenserver/zenserver.h
+++ b/src/zenserver/zenserver.h
@@ -88,6 +88,7 @@ private:
ZenServerState::ZenServerEntry* m_ServerEntry = nullptr;
bool m_IsDedicatedMode = false;
bool m_TestMode = false;
+ bool m_IsPowerCycle = false;
CbObject m_RootManifest;
std::filesystem::path m_DataRoot;
std::filesystem::path m_ContentRoot;