indexzero / daemon.node

A node.JS addon that helps to create *nix daemons in Javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong example code for daemon. Printing to stdout without setting it to any file after daemon

goelvivek opened this issue · comments

// this code is run twice
// see implementation notes below
console.log(process.pid);

// after this point, we are a daemon
require('daemon')();

//As stdout is closed here. process.pid will not get printed anywhere. 
console.log(process.pid);

process.pid will get printed to whatever stdout option you passed to the daemon function. I believe if you don't pass anything, then yes, it won't go anywhere. However you can pass a file stream and that should work.

I am getting following output. If I run sample program.

31343

But according to the example code. It should print two pid.