aboutsummaryrefslogtreecommitdiff
path: root/src/zen/zen.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-15 18:53:38 +0200
committerGitHub <[email protected]>2023-05-15 18:53:38 +0200
commit3fb79e25865c3bafa9156c2db767ddc16f5019f3 (patch)
treed476cf8c3b05793642b1a029171d76dfcf9f092d /src/zen/zen.cpp
parentadded trace::DescribeSession to TraceInit (diff)
downloadarchived-zen-3fb79e25865c3bafa9156c2db767ddc16f5019f3.tar.xz
archived-zen-3fb79e25865c3bafa9156c2db767ddc16f5019f3.zip
Better defaults for zen cli (#302)
added ZenCmdBase::ResolveTargetHostSpec - this is a helper which provides better default behaviour for commands which interact with a local zen server instance. more specifically it picks a default based on which processes are actually running on the local machine this change also wires up the Scrub command along with some required HttpClient improvements
Diffstat (limited to 'src/zen/zen.cpp')
-rw-r--r--src/zen/zen.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp
index 7f0549d42..3ae62e29d 100644
--- a/src/zen/zen.cpp
+++ b/src/zen/zen.cpp
@@ -23,8 +23,8 @@
#include <zencore/logging.h>
#include <zencore/scopeguard.h>
#include <zencore/string.h>
-
#include <zenhttp/httpcommon.h>
+#include <zenutil/zenserverprocess.h>
#if ZEN_WITH_TESTS
# define ZEN_TEST_WITH_RUNNER 1
@@ -208,6 +208,7 @@ main(int argc, char** argv)
RpcReplayCommand RpcReplayCmd;
RpcStartRecordingCommand RpcStartRecordingCmd;
RpcStopRecordingCommand RpcStopRecordingCmd;
+ ScrubCommand ScrubCmd;
StatusCommand StatusCmd;
TopCommand TopCmd;
UpCommand UpCmd;
@@ -248,6 +249,7 @@ main(int argc, char** argv)
{"rpc-record-replay", &RpcReplayCmd, "Stops recording of cache rpc requests on a host"},
{"rpc-record-start", &RpcStartRecordingCmd, "Replays a previously recorded session of rpc requests"},
{"rpc-record-stop", &RpcStopRecordingCmd, "Starts recording of cache rpc requests on a host"},
+ {"scrub", &ScrubCmd, "Scrub zen storage (verify data integrity)"},
{"status", &StatusCmd, "Show zen status"},
{"top", &TopCmd, "Monitor zen server activity"},
{"up", &UpCmd, "Bring zen server up"},
@@ -435,3 +437,28 @@ main(int argc, char** argv)
return 0;
}
+
+std::string
+ZenCmdBase::ResolveTargetHostSpec(const std::string& InHostSpec)
+{
+ if (InHostSpec.empty())
+ {
+ zen::ZenServerState Servers;
+
+ if (Servers.InitializeReadOnly())
+ {
+ std::string ResolvedSpec = InHostSpec;
+
+ Servers.Snapshot([&](const zen::ZenServerState::ZenServerEntry& Entry) {
+ if (ResolvedSpec.empty())
+ {
+ ResolvedSpec = fmt::format("http://localhost:{}", Entry.EffectiveListenPort);
+ }
+ });
+
+ return ResolvedSpec;
+ }
+ }
+
+ return InHostSpec;
+}