From b590b4e943de3de71f90ae9f6fb9068f3334ae54 Mon Sep 17 00:00:00 2001 From: Andrea Fontana Date: Mon, 16 Dec 2024 10:01:15 +0100 Subject: [PATCH] Fix args management on workrs --- source/serverino/daemon.d | 4 ++++ source/serverino/main.d | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/source/serverino/daemon.d b/source/serverino/daemon.d index d9d4f2a..d23f0b3 100644 --- a/source/serverino/daemon.d +++ b/source/serverino/daemon.d @@ -377,9 +377,12 @@ package: import std.digest : toHexString; import std.ascii : LetterCase; import core.runtime : Runtime; + import std.base64 : Base64; + import std.string : join, representation; immutable daemonPid = thisProcessID.to!string; immutable canaryFileName = tempDir.buildPath("serverino-" ~ daemonPid ~ "-" ~ sha256Of(daemonPid).toHexString!(LetterCase.lower) ~ ".canary"); + immutable argsBkp = Base64.encode(Runtime.args.join("\0").representation); version(Posix) { @@ -398,6 +401,7 @@ package: workerEnvironment = environment.toAA(); workerEnvironment["SERVERINO_DAEMON"] = daemonPid; workerEnvironment["SERVERINO_BUILD"] = Request.simpleNotSecureCompileTimeHash(); + workerEnvironment["SERVERINO_ARGS"] = argsBkp; void removeCanary() { remove(canaryFileName); } void writeCanary() { File(canaryFileName, "w").write("delete this file to reload serverino workers (process id: " ~ daemonPid ~ ")\n"); } diff --git a/source/serverino/main.d b/source/serverino/main.d index a9a2534..2bd4d80 100644 --- a/source/serverino/main.d +++ b/source/serverino/main.d @@ -104,6 +104,10 @@ template ServerinoMain(Modules...) int main(string[] args) { + import std.base64 : Base64; + if (environment.get("SERVERINO_DAEMON") !is null) + args = (cast(string)Base64.decode(environment.get("SERVERINO_ARGS"))).split("\0"); + return mainServerinoLoop(args); } }