From 821523aa27a0e18f2af78c237bb11a4c64397739 Mon Sep 17 00:00:00 2001 From: Viktor Nonov Date: Sat, 13 Oct 2018 11:55:56 -0700 Subject: [PATCH] [doc] Add example for passing file descriptors for stderr and stdout --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 45495b0..f42fecb 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,17 @@ opt can optionally contain the following arguments: * env (environment for the daemon) (default: process.env) * cwd (current working directory for daemonized script) (default: process.cwd) +Example for passing file descriptors for stdout and stderr: +```javascript +var fs = require('fs'), +var stdoutFd = fs.openSync('output.log', 'a'); +var stderrFd = fs.openSync('errors.log', 'a'); +require('daemon')({ + stdout: stdoutFd, + stderr: stderrFd +}); +``` + ## implementation notes Daemon actually re-spawns the current application and runs it again. The only difference between the original and the fork is that the original will not execute past the `daemon()` call whereas the fork will.