Name: js-handler/node_modules/daemon/README.md 
1:
# daemon
2:
 
3:
[![Build Status](https://secure.travis-ci.org/indexzero/daemon.node.png)](http://travis-ci.org/indexzero/daemon.node)
4:
 
5:
Turn a node script into a daemon.
6:
 
7:
## install via npm
8:
 
9:
```
10:
npm install daemon
11:
```
12:
 
13:
Requires node >= 0.8
14:
 
15:
## examples
16:
 
17:
```javascript
18:
// this code is run twice
19:
// see implementation notes below
20:
console.log(process.pid);
21:
 
22:
// after this point, we are a daemon
23:
require('daemon')();
24:
 
25:
// different pid because we are now forked
26:
// original parent has exited
27:
console.log(process.pid);
28:
```
29:
 
30:
## api
31:
 
32:
### daemon()
33:
 
34:
Respawn the process (self) as a daemon. The parent process will exit at the point of this call.
35:
 
36:
### daemon.daemon(script, args, opt)
37:
 
38:
Spawn the `script` with given `args` array as a daemonized process. Return the `child` process object.
39:
 
40:
opt can optionally contain the following arguments:
41:
* stdout (file descriptor for stdout of the daemon)
42:
* stderr (file descriptor for stderr of the daemon)
43:
* env (environment for the daemon) (default: process.env)
44:
* cwd (current working directory for daemonized script) (default: process.cwd)
45:
 
46:
## implementation notes
47:
 
48:
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.
49:
 
50:
## node versions prior to 0.8
51:
 
52:
Using this module on older versions of node (or older versions of this module) are not recommended due to how node works internally and the issues it can cause for daemons.
53:
 
54:
## Contributors
55:
[Charlie Robbins](http://nodejitsu.com)  
56:
[Pedro Teixeira](https://github.com/pgte)  
57:
[James Halliday](https://github.com/substack)  
58:
[Zak Taylor](https://github.com/dobl)  
59:
[Daniel Bartlett](https://github.com/danbuk)  
60:
[Charlie McConnell](https://github.com/AvianFlu)  
61:
[Slashed](http://github.com/slashed)  
62:
[Roman Shtylman](http://github.com/shtylman)