Package Exports
- node-persistent-software
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-persistent-software) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-persistent-software
Spawn a software and keep it running
Installation
$ npm install node-persistent-software
Doc (extends : asynchronous-eventemitter)
Attributes
string software
path to the softwarearray arguments
arguments passed to the softwareobject options
options passed to the softwareobject currentChildProcess
current child_processboolean ended
if ended, don't restart itint maxCountRun
max start iterationint successCountRun
current success start iterationasynchronous-eventemitter eventEmitter
async events manager
Constructor
constructor(string software [, array arguments [ , object options ] ] )
=> see spawn documentation
Methods
max(int maxIteration) : 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 don't restart it
Events
on("error", (string err) => {}) : this
fire if an error occurs (use try/catch to avoid loop)on("firststart", () => {}) : this
fire if the software starts for the first timeon("restart", () => {}) : this
fire if the software restartson("start", (object child_process) => {}) : this
fire if the software starts (firststart && restart) => see spawn documentationon("stop", () => {}) : this
fire if the software is killedon("end", () => {}) : this
fire if the software is killed and cannot be restarted
Examples
const PersistantSoftware = require('node-persistent-software');
new PersistantSoftware(
"C:\\Program Files\\Mozilla Firefox\\firefox.exe",
[ "https://www.npmjs.com/package/node-persistent-software" ]
).on("error", (msg) => {
console.log(msg);
})
.infinite()
.on("firststart", () => {
console.log("Firefox is started for the first time !");
}).on("restart", () => {
console.log("Firefox is started again...");
}).on("start", (child_process) => {
console.log("anyway, Firefox is started.");
})
.on("stop", () => {
console.log("Firefox is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ Firefox is stopped and cannot be restarted /!\\");
}).start();
new PersistantSoftware(
"C:\\Program Files\\Mozilla Firefox\\firefox.exe",
[ "https://github.com/Psychopoulet/node-persistent-software" ]
).on("error", (msg) {
console.log(msg);
})
.max(5)
.on("firststart", () => {
console.log("Firefox is started for the first time !");
}).on("restart", () => {
console.log("Firefox is started again...");
}).on("start", () => {
console.log("anyway, Firefox is started.");
})
.on("stop", () => {
console.log("Firefox is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ Firefox is stopped and cannot be restarted /!\\");
}).start();
Tests
$ npm test