revive v1.1.8
Process Management Tool | Auto Restarts | Advanced Events | And More Warning 1.1.1 Breaking API Changes
Revive
A process management tool. Events, status, cluster, and automatic restarts.
Install
npm install reviveExample
const Revive = require('revive');
const options = {
	name: 'test',
	cmd: process.execPath,
	arg: ['app.js'],
	env: { PORT: 8000 },
	cwd: '/home/user/code/node/app/.',
	cluster: true,
	instances: 2,
	stdout: '/logs/stdout.log',
	stderr: '/logs/stderr.log',
	sleepTime: 1000,
	crashTime: 6 * 1000,
	maxCrashCount: 1000
};
const monitor = Revive(options);
monitor.on('start', function () {
	console.log(monitor.toJSON());
});
monitor.start();Options
name: StringDefaults tonullthe name of the process.arg: Array, StringDefaults tonullarguments or node script.cwd: StringDefaults toprocess.cwd()the current working directory.cmd: StringDefaults toprocess.execPaththe systems absolute executable/node path.cluster: BooleanDefaults tofalse.instances: NumberDefaults toOs.cpus().lengthif cluster is set totruestdout: StringDefaults to'pipe'otherwise a file path. If a path is provided than this event will not fire.stderr: StringDefaults to'pipe'otherwise a file path. If a path is provided than this event will not fire.sleepTime: Array, NumberDefaults to1000in milliseconds to sleep between start after a crash.crashTime: NumberDefaults to60000ms. The time until themaxCrashCountresets. So if1000crashes happen in60s then the process will exit.maxCrashCount: NumberDefaults to1000crashes. A crash is triggered and the process exited atnth + 1.env: {}Environment variables for the process.data: {}A custom object for you.
API
monitor.start()Starts the monitormonitor.stop()Stops the monitor (kills the process if its running withSIGKILL).monitor.restart()Restarts the monitor by stopping then starting (process must be started).monitor.toJSON()Creates a stringyifiable object. The object returns stats and data about the process.
Cluster Events
monitor.on('status', callback)monitor.on('start', callback)Starts the process. Warning async so process may not be available immediately.monitor.on('stop', callback)The process and it's tree is sent aSIGTERMsignal. If the process does not terminate after ten seconds then the process is sent aSIGKILLsignal.monitor.on('restart', callback)Same as stopping then starting or vice versa.monitor.on('stdout', callback)Emits an stdout. Only available if noOptions.stdoutispipe. -StdoutParameter the stdout message.monitor.on('stderr', callback)Emits an stderr. Only available if noOptions.stderrispipe. -StderrParameter the stderr message.monitor.on('error', callback)Emits when the process could not spawn, kill, or a message failed. -ErrorParameter the error message.monitor.on('exit', callback)The process has exited. -CodeThe numeric exit code -SignalThe string signal
Instance Events
monitor.on('reload', callback)Zero downtime restart ifclusteris set totrueandinstancesis greater than one.monitor.on('sleep', callback)Triggered when process crashes and enters sleep.monitor.on('crash', callback)Triggered when the process crashes.
Issues
Immediate start then stop execution does not send the signals. This could be a problem with node.js.
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago