aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-04-24 12:46:34 +0200
committerGitHub <[email protected]>2023-04-24 12:46:34 +0200
commitf41415f7f81d1bfdf9243e7da91ec80f27df064a (patch)
treee6aa55b7487ea69bb2a109268ddee1b8c8d97800
parentcheck for port conflict before trying to take data dir lock (#253) (diff)
downloadzen-f41415f7f81d1bfdf9243e7da91ec80f27df064a.tar.xz
zen-f41415f7f81d1bfdf9243e7da91ec80f27df064a.zip
fix down command (#254)
* add option to zen down command to control port * use correct port for shutdown even when attaching to running server * changelog
-rw-r--r--CHANGELOG.md2
-rw-r--r--zen/cmds/up.cpp16
-rw-r--r--zen/cmds/up.h1
-rw-r--r--zenutil/zenserverprocess.cpp2
4 files changed, 14 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8380bf3c9..a2c69eab4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,9 +46,11 @@
- Feature: `--junit` switch to `xmake test` to generate junit style reports of tests.
- Feature: CI build on GitHub now uploads junit test reports as artifact to the check for PR validation and mainline validation
- Feature: Payloads from zenserver can now be sent using duplicated file handles if caller requests provides client ProcessId (Windows only).
+- Feature: Add `--port` option to zen down command to shut down servers on different base ports
- Bugfix: Make sure async responses are sent async correctly in httpsys
- Bugfix: Don't delete manifest file in cas root when initializing a new filecas folder
- Bugfix: Sentry does not like UNC paths, so strip the prefix before passing them to sentry
+- Bugfix: Make sure zen down command uses the correct port for shutdown event
- Improvement: FileCas now keeps an up to date index of all the entries improving performance when getting cache misses on large payloads
- Improvement: Structured cache now keeps RawHash and RawSize in memory avoiding materialization of cache values before sending response
- Changed: Exit with failure code on port conflict rather than reporting crash to Sentry
diff --git a/zen/cmds/up.cpp b/zen/cmds/up.cpp
index 9fa1cdd8c..69bcbe829 100644
--- a/zen/cmds/up.cpp
+++ b/zen/cmds/up.cpp
@@ -46,6 +46,7 @@ UpCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
DownCommand::DownCommand()
{
+ m_Options.add_option("", "p", "port", "Host port", cxxopts::value(m_Port)->default_value("1337"), "<hostport>");
}
DownCommand::~DownCommand() = default;
@@ -53,15 +54,17 @@ DownCommand::~DownCommand() = default;
int
DownCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
{
- ZEN_UNUSED(GlobalOptions, argc, argv);
-
- int ListenPort = 1337;
+ ZEN_UNUSED(GlobalOptions);
+ if (!ParseOptions(argc, argv))
+ {
+ return 0;
+ }
// Discover executing instances
ZenServerState Instance;
Instance.Initialize();
- ZenServerState::ZenServerEntry* Entry = Instance.Lookup(ListenPort);
+ ZenServerState::ZenServerEntry* Entry = Instance.Lookup(m_Port);
if (!Entry)
{
@@ -77,9 +80,9 @@ DownCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
ZenServerEnvironment ServerEnvironment;
ServerEnvironment.Initialize(ExePath.parent_path());
ZenServerInstance Server(ServerEnvironment);
- Server.AttachToRunningServer(ListenPort);
+ Server.AttachToRunningServer(m_Port);
- ZEN_CONSOLE("attached to server on port {}, requesting shutdown", ListenPort);
+ ZEN_CONSOLE("attached to server on port {}, requesting shutdown", m_Port);
Server.Shutdown();
@@ -96,6 +99,7 @@ DownCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
// handle to determine when the server has shut down. Thus we signal that we would like
// a shutdown via the shutdown flag and then
+ ZEN_CONSOLE("requesting shutdown of server on port {}", m_Port);
Entry->SignalShutdownRequest();
return 0;
diff --git a/zen/cmds/up.h b/zen/cmds/up.h
index c0f1beaba..5af05541a 100644
--- a/zen/cmds/up.h
+++ b/zen/cmds/up.h
@@ -30,6 +30,7 @@ public:
private:
cxxopts::Options m_Options{"down", "Bring down zen service"};
+ uint16_t m_Port;
};
} // namespace zen
diff --git a/zenutil/zenserverprocess.cpp b/zenutil/zenserverprocess.cpp
index b43313b7c..659eb665b 100644
--- a/zenutil/zenserverprocess.cpp
+++ b/zenutil/zenserverprocess.cpp
@@ -612,7 +612,7 @@ ZenServerInstance::AttachToRunningServer(int BasePort)
}
m_Process.Initialize(Entry->Pid);
- CreateShutdownEvent(BasePort);
+ CreateShutdownEvent(Entry->EffectiveListenPort);
}
void