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