diff options
| author | Stefan Boberg <[email protected]> | 2023-11-23 13:43:37 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-23 13:43:37 +0100 |
| commit | 48f4a8bce0450263cda89d3b33fc15e32620e6f4 (patch) | |
| tree | a4e28d9b3922f8934f1a01bd87b0674268620ba4 /src/zenserver | |
| parent | 0.2.36-pre1 (diff) | |
| download | zen-48f4a8bce0450263cda89d3b33fc15e32620e6f4.tar.xz zen-48f4a8bce0450263cda89d3b33fc15e32620e6f4.zip | |
added --powercycle option (#565)
* added --powercycle option. when this is passed in the zenserver process will shut down immediately after initialization is complete. This is primarily useful when benchmarking init/cleanup but could also be used to verify/clean up disk state
* moved EmptyStandbyList code to make it accessible to more commands
Diffstat (limited to 'src/zenserver')
| -rw-r--r-- | src/zenserver/config.cpp | 3 | ||||
| -rw-r--r-- | src/zenserver/config.h | 1 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 8 | ||||
| -rw-r--r-- | src/zenserver/zenserver.h | 1 |
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; |