JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q33600F
  • License ISC

Spawn a software and keep it running

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 software
  • array arguments arguments passed to the software
  • object options options passed to the software
  • object currentChildProcess current child_process
  • boolean ended if ended, don't restart it
  • int maxCountRun max start iteration
  • int successCountRun current success start iteration
  • asynchronous-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 current
  • infinite() : this no max iteration and reset current
  • start() : this run the software for the first time
  • end() : 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 time

  • on("restart", () => {}) : this fire if the software restarts

  • on("start", (object child_process) => {}) : this fire if the software starts (firststart && restart) => see spawn documentation

  • on("stop", () => {}) : this fire if the software is killed

  • on("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

License

ISC