Start and stop child daemon processes without cutting them loose

npm install child-daemon
18 downloads in the last day
238 downloads in the last week
922 downloads in the last month


Start and stop child daemon processes without cutting them loose


  • should start and stop child daemon processes
  • should error if an invalid child is specified
  • should error if stopped before started
  • should error if started when already running
  • should work with processes that buffer output when there is no tty
  • should support windows and *nix systems


npm install child-daemon


var ChildDaemon = require('child-daemon');

var childDaemon = new ChildDaemon(
  command, // command
  args, // argument array
  new RegExp(regexString) // regular expression which when matched to ouput from stdout or stderr will indicate that the daemon has started and is ready 

childDaemon.start(function(error, matched) {
  if (error) {
    // Daemon failed to start, or exited before the regular expression was matched
  } else {
    // Daemon started, the matched parameter will be the returned array from the matched regular expression

    childDaemon.stop(function(error) {
      if (error) {
        // Daemon failed to stop (perhaps the daemon is no longer running)
      } else {
        // Daemon was stopped


  • nothing yet


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using ./ or .\grunt.bat.


Copyright (c) 2012 Peter Halliday
Licensed under the MIT license.

npm loves you