diff options
| author | Dan Engelbrecht <[email protected]> | 2024-04-18 12:44:26 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-04-18 12:44:26 +0200 |
| commit | 6d634ab59c05adf1ba028d95b16031a7f8e8db2a (patch) | |
| tree | 87e8215fed65506f98f6838b2af08c4ffd5819f0 /src/zenserver/main.cpp | |
| parent | zen startup hardening (#49) (diff) | |
| download | zen-6d634ab59c05adf1ba028d95b16031a7f8e8db2a.tar.xz zen-6d634ab59c05adf1ba028d95b16031a7f8e8db2a.zip | |
improved lock file handling (#50)
- Feature: `zen down`
- --`data-dir` to specify a data directory to deduce which zen instance to bring down
- Feature: `zen attach`
- --`data-dir` to specify a data directory to deduce which zen instance to attach to222
- Feature: `zen status`
- --`port` filter running zen instances based on port
- --`data-dir` filter running zen instances based on information in the data directory
- Improvement: Trying to load a compact binary object from an empty file no longer causes access violation
Diffstat (limited to 'src/zenserver/main.cpp')
| -rw-r--r-- | src/zenserver/main.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 2d2b24bbb..8715f5447 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -153,23 +153,23 @@ ZenEntryPoint::Run() std::filesystem::path LockFilePath = m_ServerOptions.DataDir / ".lock"; - bool IsReady = false; - - auto MakeLockData = [&] { - CbObjectWriter Cbo; - Cbo << "pid" << GetCurrentProcessId() << "data" << PathToUtf8(m_ServerOptions.DataDir) << "port" << m_ServerOptions.BasePort - << "session_id" << GetSessionId() << "ready" << IsReady; - return Cbo.Save(); + auto MakeLockData = [&](bool IsReady) { + return MakeLockFilePayload({.Pid = GetCurrentProcessId(), + .SessionId = GetSessionId(), + .EffectiveListenPort = gsl::narrow<uint16_t>(m_ServerOptions.BasePort), + .Ready = IsReady, + .DataDir = m_ServerOptions.DataDir, + .ExecutablePath = GetRunningExecutablePath()}); }; - m_LockFile.Create(LockFilePath, MakeLockData(), Ec); + m_LockFile.Create(LockFilePath, MakeLockData(false), Ec); if (Ec) { ZEN_WARN("Unable to grab lock at '{}' (error: '{}'), retrying", LockFilePath, Ec.message()); Sleep(500); - m_LockFile.Create(LockFilePath, MakeLockData(), Ec); + m_LockFile.Create(LockFilePath, MakeLockData(false), Ec); if (Ec) { ZEN_WARN("ERROR: Unable to grab lock at '{}' (error: '{}')", LockFilePath, Ec.message()); @@ -255,9 +255,7 @@ ZenEntryPoint::Run() // to be able to communicate readiness with the parent Server.SetIsReadyFunc([&] { - IsReady = true; - - m_LockFile.Update(MakeLockData(), Ec); + m_LockFile.Update(MakeLockData(true), Ec); if (!m_ServerOptions.ChildId.empty()) { |