aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/status_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zen/cmds/status_cmd.cpp')
-rw-r--r--src/zen/cmds/status_cmd.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/zen/cmds/status_cmd.cpp b/src/zen/cmds/status_cmd.cpp
new file mode 100644
index 000000000..cc936835a
--- /dev/null
+++ b/src/zen/cmds/status_cmd.cpp
@@ -0,0 +1,42 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "status_cmd.h"
+
+#include <zencore/fmtutils.h>
+#include <zencore/logging.h>
+#include <zencore/string.h>
+#include <zencore/uid.h>
+#include <zenutil/zenserverprocess.h>
+
+namespace zen {
+
+StatusCommand::StatusCommand()
+{
+}
+
+StatusCommand::~StatusCommand() = default;
+
+int
+StatusCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
+{
+ ZEN_UNUSED(GlobalOptions, argc, argv);
+
+ ZenServerState State;
+ if (!State.InitializeReadOnly())
+ {
+ ZEN_CONSOLE("no Zen state found");
+
+ return 0;
+ }
+
+ ZEN_CONSOLE("{:>5} {:>6} {:>24}", "port", "pid", "session");
+ State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) {
+ StringBuilder<25> SessionStringBuilder;
+ Entry.GetSessionId().ToString(SessionStringBuilder);
+ ZEN_CONSOLE("{:>5} {:>6} {:>24}", Entry.EffectiveListenPort.load(), Entry.Pid.load(), SessionStringBuilder);
+ });
+
+ return 0;
+}
+
+} // namespace zen