1.2.0 • Published 6 years ago
@nore/pm v1.2.0
@nore/pm
A cross-platform Node.js process manager.
Install
npm install @nore/pmUsage
import PM from "@nore/pm";
const command = ["node", "script.js", "--debug"];
const options = { cwd: "/path/to/directory", restartLimit: 2 };
const pm = new PM(command, options);Options:
killTimeout– wait?milliseconds for the process to exit else send a SIGKILL, default:30000restartDelay– wait?milliseconds between restarts, default:1000restartLimit– the number of times a process can be restarted automatically; settingnullwill restart it indefinitely, default:0- other options are directly passed to the spawned process, follow the official documentation
API
awaitpm.start()– start the processawaitpm.stop()– stop the processawaitpm.restart()– restart the processpm.on('start' () => {})– emitted when the process is startedpm.on('stop' () => {})– emitted when the process is stoppedpm.on('spawn', (process) => {})– emitted when a new process was spawnedpm.on('error', (error) => {})– emitted on process errorpm.on('exit', (code, signal) => {})– emitted on process exitpm.status– the status of the process
pm.status:
initial– the inital state after creating thepminstancerunning– after the process was startedsleeping– during the delay period while the process is restartingstopping– during the.stop()processstopped– after the.stop()was completedcrashed– process crashed on error or exited without being stopped