Skip to content

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

@jhuckaby

Description

@jhuckaby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions