daemon
Add-on for creating *nix daemons
Last updated 7 years ago by shtylman .
Repository · Original npm · Tarball · package.json
$ cnpm install daemon 
SYNC missed versions from official npm registry.

daemon

Build Status

Turn a node script into a daemon.

install via npm

npm install daemon

Requires node >= 0.8

examples

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

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

// different pid because we are now forked
// original parent has exited
console.log(process.pid);

api

daemon()

Respawn the process (self) as a daemon. The parent process will exit at the point of this call.

daemon.daemon(script, args, opt)

Spawn the script with given args array as a daemonized process. Return the child process object.

opt can optionally contain the following arguments:

  • stdout (file descriptor for stdout of the daemon)
  • stderr (file descriptor for stderr of the daemon)
  • env (environment for the daemon) (default: process.env)
  • cwd (current working directory for daemonized script) (default: process.cwd)

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.

node versions prior to 0.8

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.

Contributors

Charlie Robbins
Pedro Teixeira
James Halliday
Zak Taylor
Daniel Bartlett
Charlie McConnell
Slashed
Roman Shtylman

Current Tags

  • 1.1.0                                ...           latest (7 years ago)
  • 0.1.0                                ...           stable (9 years ago)

9 Versions

  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.5.1                                ...           8 years ago
  • 0.5.0                                ...           8 years ago
  • 0.4.1                                ...           8 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.2                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
Downloads
Today 23
This Week 127
This Month 78
Last Day 33
Last Week 171
Last Month 636
Dependencies (0)
None
Dev Dependencies (2)
Dependents (183)

Copyright 2014 - 2017 © taobao.org |