Skip to content

Tips: passing params from main process (daemon) to workers

Andrea Fontana edited this page Mar 1, 2024 · 1 revision

Env vars are copied from daemon process to workers:

@onDaemonStart void start()
{
	// This code runs in the daemon process, before the workers are started.
	environment["args"] = Runtime.args.join(", "); 		// The command line arguments.
	environment["data"] = `{"name": "John", "age": 30}`;	// Some data.
}


void dump(Request request, Output output)
{
	// Here we can access (from the worker process) the environment variables set in the start() function.
	output.addHeader("content-type", "text/plain");
	output ~= "Args: " ~ environment["args"] ~ "\n";
	output ~= "Data: " ~ environment["data"] ~ "\n";
}