Skip to content

Commit

Permalink
Fix args management on workrs
Browse files Browse the repository at this point in the history
  • Loading branch information
trikko committed Dec 16, 2024
1 parent 536fbdd commit b590b4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/serverino/daemon.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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"); }
Expand Down
4 changes: 4 additions & 0 deletions source/serverino/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit b590b4e

Please sign in to comment.