daemon.node icon indicating copy to clipboard operation
daemon.node copied to clipboard

Daemon fork doesn't inherit Node CLI flags such as --enable_gc

Open jhuckaby opened this issue 9 years ago • 0 comments

I discovered that if my node script was launched with any Node CLI flags such as --enable_gc (which exposes the internal Node Garbage Collector), this flag does not pass down to the daemon fork. Example:

node --enable_gc mydaemon.js

I see that internal node flags are not included on the process.argv array, so there is apparently no way the daemon module can preserve them.

I worked around this by detecting the presence of global.gc and then splicing the --enable_gc flag back into the process.argv array just before calling daemon:

if (!process.env.__daemon && global.gc) {
    process.argv.splice( 1, 0, '--expose_gc' );
}
require('daemon')();

- Joe

jhuckaby avatar Mar 13 '16 21:03 jhuckaby