node-persistent-software
Spawn a software and keep it running
Installation
$ npm install node-persistent-software
asynchronous-eventemitter)
Doc (extends :Attributes
maxCountRun: number
max start iterationsuccessCountRun: number
current success start iteration
Constructor
constructor(software: string, args?: Array<string>, options?: object)
=> see spawn documentation
Methods
max(maxIteration: number) : this
change max iterations and reset currentinfinite() : this
no max iteration and reset currentstart() : this
run the software for the first timeend() : this
stop the software and does not restart it
Events
-
on("error", (err: Error) => void) : this
fire if an error occurs (use try/catch to avoid loop) -
on("firststart", () => void) : this
fire if the software starts for the first time -
on("restart", () => void) : this
fire if the software restarts -
on("start", (child_process: child_process.ChildProcess) => void) : this
fire if the software starts (firststart && restart) => see spawn documentation -
on("stop", () => void) : this
fire if the software is killed -
on("end", () => void) : this
fire if the software is killed and cannot be restarted
Examples
Native
const PersistantSoftware = ; "node" "-v" start; "node" "-v" start;
Typescript
; new PersistantSoftware"node", .on"error", .infinite;
Tests
$ npm run-script tests