pm2-state-helper

0.1.0 • Public • Published

PM2-State-Helper - Exit With Grace

Intro

Simple module which allows a process running under PM2 to start and stop gracefully.

const state = require('pm2-state-helper');
const server = require('http').createServer();

// Handle stopping
state.onStopping(callback => {
    // Handle your stuff here...

    // Do stuff...
    // Do stuff...

    server.close(callback); // Finally let us know its over
});

// Notify start
server.listen('8080', () => {
    state.started();
});

Notes

onStopping also accepts a function that returns a Promise instead of one accepting the callback.

Readme

Keywords

Package Sidebar

Install

npm i pm2-state-helper

Weekly Downloads

19

Version

0.1.0

License

ISC

Unpacked Size

2.93 kB

Total Files

3

Last publish

Collaborators

  • magaya