diff options
Diffstat (limited to 'src/zen/zen.cpp')
| -rw-r--r-- | src/zen/zen.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp index 7f5c50b2f..550edb7ef 100644 --- a/src/zen/zen.cpp +++ b/src/zen/zen.cpp @@ -19,6 +19,7 @@ #include "cmds/projectstore_cmd.h" #include "cmds/serve_cmd.h" #include "cmds/service_cmd.h" +#include "cmds/sessions_cmd.h" #include "cmds/status_cmd.h" #include "cmds/top_cmd.h" #include "cmds/ui_cmd.h" @@ -38,6 +39,7 @@ #include <zencore/process.h> #include <zencore/scopeguard.h> #include <zencore/sentryintegration.h> +#include <zencore/session.h> #include <zencore/string.h> #include <zencore/trace.h> #include <zencore/windows.h> @@ -687,6 +689,7 @@ main(int argc, char** argv) RpcStopRecordingCommand RpcStopRecordingCmd; ScrubCommand ScrubCmd; ServeCommand ServeCmd; + SessionsCommand SessionsCmd; StatusCommand StatusCmd; LoggingCommand LoggingCmd; TopCommand TopCmd; @@ -754,6 +757,7 @@ main(int argc, char** argv) {RpcStopRecordingCommand::Name, &RpcStopRecordingCmd, RpcStopRecordingCommand::Description}, {ScrubCommand::Name, &ScrubCmd, ScrubCommand::Description}, {ServeCommand::Name, &ServeCmd, ServeCommand::Description}, + {SessionsCommand::Name, &SessionsCmd, SessionsCommand::Description}, {StatusCommand::Name, &StatusCmd, StatusCommand::Description}, {TopCommand::Name, &TopCmd, TopCommand::Description}, {TraceCommand::Name, &TraceCmd, TraceCommand::Description}, @@ -863,6 +867,7 @@ main(int argc, char** argv) GlobalOptions.PassthroughArgV = PassthroughArgV; std::string MemoryOptions; + std::string ParentSessionId; std::string SubCommand = "<None>"; @@ -879,6 +884,9 @@ main(int argc, char** argv) Options.add_options()("httpclient", "Select HTTP client implementation", cxxopts::value<std::string>(GlobalOptions.HttpClientBackend)->default_value("curl")); + Options.add_options()("parent-session", + "Specify parent session id used to associate this process with another session", + cxxopts::value<std::string>(ParentSessionId)); int CoreLimit = 0; @@ -979,6 +987,19 @@ main(int argc, char** argv) LimitHardwareConcurrency(CoreLimit); + if (!ParentSessionId.empty()) + { + Oid ParsedParentSessionId; + if (!Oid::TryParse(ParentSessionId, ParsedParentSessionId) || ParsedParentSessionId == Oid::Zero) + { + throw zen::OptionParseException( + fmt::format("invalid parent session id '{}': expected a 24-character object id", ParentSessionId), + Options.help()); + } + GlobalOptions.ParentSessionId = ParsedParentSessionId; + SetParentSessionId(ParsedParentSessionId); + } + #if ZEN_USE_SENTRY { EnvironmentOptions EnvOptions; @@ -1070,6 +1091,12 @@ main(int argc, char** argv) { try { + // Bootstrap window is closed: option parsing is done, + // logging is fully wired, the command is about to run. + // Drop the captured backlog so it doesn't pin memory + // for the rest of the command's lifetime. + DisableLogBacklog(); + CmdInfo.Cmd->Run(GlobalOptions, (int)CommandArgVec.size(), CommandArgVec.data()); return (int)ReturnCode::kSuccess; } |