GithubHelp home page GithubHelp logo

respawn-group's Introduction

respawn-group

Manage a group of respawn monitors

npm install respawn-group

Usage

var regroup = require('respawn-group');
var group = regroup();

group.add('test', ['node', 'server.js']);
group.start('test');

API

  • regroup(defaults) -> group Instantiate a new respawn group. All opts will inherit from defaults

  • group.add(id, command, opts) -> mon Add a new respawn monitor. See respawn for more information. If you add a new monitor with the same id as an old one it will be used when the old monitor stops.

  • group.remove(id, cb) Remove a monitor

  • group.start(id) -> mon Start a monitor

  • group.stop(id, cb) Stop a monitor

  • group.restart(id) -> mon Gracefully restart a monitor

  • group.get(id) -> mon Get a monitor

  • group.has(id) -> bool True is group has monitor

  • group.list() -> array List all monitors

  • group.shutdown(cb) Stop all services and ignore all following starts

Events

  • group.on('start', mon) Monitor has started. mon.id contains the id of the monitor

  • group.on('stop', mon) Monitor is fully stopped

  • group.on('crash', mon) Monitor has crashed

  • group.on('restart', mon) Monitor is being restarted

  • group.on('sleep', mon) Monitor is sleeping

  • group.on('spawn', mon, process) Monitor has spawned a child process

  • group.on('exit', mon, code, signal) Monitors child process has exited

  • group.on('stdout', mon, data) child process stdout has emitted data

  • group.on('stderr', mon, data) child process stderr has emitted data

  • group.on('warn', mon, err) Monitor has a warning

  • group.on('finalize', mon) A monitor is fully stopped and being garbage collected. Happens if you call remove or updates a monitor

Updating existing monitors

To update an existing monitor simply add it again with the same id

group.add('test', ['node', 'server.js']);

// ... wait a bit ...
// now lets update test

group.add('test', ['node', 'server2.js']);
group.restart('test'); // you need to restart test for the new monitor to take over
                       // this will trigger a 'finalize' event for the old monitor

License

MIT

respawn-group's People

Contributors

mafintosh avatar steffentchr avatar typicode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.