aboutsummaryrefslogtreecommitdiff
path: root/src/zen/zen.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-06-16 17:02:23 +0200
committerGitHub <[email protected]>2023-06-16 17:02:23 +0200
commit86418ed57c677ffc8ce314acfcf9b9f1eab3586b (patch)
treed197ea40f2e8255338c806a27e82ae289a33bf68 /src/zen/zen.cpp
parentadded ZenServerInstance::SpawnServerAndWait (#334) (diff)
downloadarchived-zen-86418ed57c677ffc8ce314acfcf9b9f1eab3586b.tar.xz
archived-zen-86418ed57c677ffc8ce314acfcf9b9f1eab3586b.zip
file share support (#328)
this change adds a serve command to the zen CLI. This can be used to establish links to a set of files which may be served to clients via the project store interface: ```cmd> zen serve Lyra/WindowsClient d:\temp_share\StagedBuilds\WindowsClient``` with the appropriate changes in UE you may then start an instance of the runtime and have it load all files via the remote file connection: ``` Lyra\Binaries\LyraClient.exe ../../../Lyra/Lyra.uproject -pak -basedir=D:\temp_share\StagedBuilds\WindowsClient/Lyra/Binaries/Win64 -Mount=Lyra/WindowsClient ```
Diffstat (limited to 'src/zen/zen.cpp')
-rw-r--r--src/zen/zen.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp
index 464b2817c..a2ab31254 100644
--- a/src/zen/zen.cpp
+++ b/src/zen/zen.cpp
@@ -14,6 +14,7 @@
#include "cmds/projectstore.h"
#include "cmds/rpcreplay.h"
#include "cmds/scrub.h"
+#include "cmds/serve.h"
#include "cmds/status.h"
#include "cmds/top.h"
#include "cmds/up.h"
@@ -207,6 +208,7 @@ main(int argc, char** argv)
RpcStartRecordingCommand RpcStartRecordingCmd;
RpcStopRecordingCommand RpcStopRecordingCmd;
ScrubCommand ScrubCmd;
+ ServeCommand ServeCmd;
SnapshotOplogCommand SnapshotOplogCmd;
StatusCommand StatusCmd;
TopCommand TopCmd;
@@ -238,6 +240,7 @@ main(int argc, char** argv)
{"oplog-create", &CreateOplogCmd, "Create a project oplog"},
{"oplog-export", &ExportOplogCmd, "Export project store oplog"},
{"oplog-import", &ImportOplogCmd, "Import project store oplog"},
+ {"oplog-snapshot", &SnapshotOplogCmd, "Snapshot project store oplog"},
{"print", &PrintCmd, "Print compact binary object"},
{"printpackage", &PrintPkgCmd, "Print compact binary package"},
{"project-create", &CreateProjectCmd, "Create a project"},
@@ -250,7 +253,7 @@ main(int argc, char** argv)
{"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)"},
- {"oplog-snapshot", &SnapshotOplogCmd, "Snapshot project store oplog"},
+ {"serve", &ServeCmd, "Serve files from a directory"},
{"status", &StatusCmd, "Show zen status"},
{"top", &TopCmd, "Monitor zen server activity"},
{"up", &UpCmd, "Bring zen server up"},
@@ -437,20 +440,24 @@ main(int argc, char** argv)
}
std::string
-ZenCmdBase::ResolveTargetHostSpec(const std::string& InHostSpec)
+ZenCmdBase::ResolveTargetHostSpec(const std::string& InHostSpec, uint16_t& OutEffectivePort)
{
if (InHostSpec.empty())
{
+ // If no host is specified then look to see if we have an instance
+ // running on this host and use that as the default to interact with
+
zen::ZenServerState Servers;
if (Servers.InitializeReadOnly())
{
- std::string ResolvedSpec = InHostSpec;
+ std::string ResolvedSpec;
Servers.Snapshot([&](const zen::ZenServerState::ZenServerEntry& Entry) {
if (ResolvedSpec.empty())
{
- ResolvedSpec = fmt::format("http://localhost:{}", Entry.EffectiveListenPort);
+ ResolvedSpec = fmt::format("http://localhost:{}", Entry.EffectiveListenPort);
+ OutEffectivePort = Entry.EffectiveListenPort;
}
});
@@ -458,5 +465,30 @@ ZenCmdBase::ResolveTargetHostSpec(const std::string& InHostSpec)
}
}
+ // Parse out port from the specification provided, to be consistent with
+ // the auto-discovery logic above.
+
+ std::string_view PortSpec(InHostSpec);
+ if (size_t PrefixIndex = PortSpec.find_last_of(":"); PrefixIndex != std::string_view::npos)
+ {
+ PortSpec.remove_prefix(PrefixIndex + 1);
+
+ std::optional<uint16_t> EffectivePort = zen::ParseInt<uint16_t>(PortSpec);
+
+ if (EffectivePort)
+ {
+ OutEffectivePort = EffectivePort.value();
+ }
+ }
+
+ // note: We should consider adding validation/normalization of the provided spec here
+
return InHostSpec;
}
+
+std::string
+ZenCmdBase::ResolveTargetHostSpec(const std::string& InHostSpec)
+{
+ uint16_t Dummy = 0;
+ return ResolveTargetHostSpec(InHostSpec, /* out */ Dummy);
+}