New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-persistent-software

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-persistent-software

Spawn a software and keep it running

latest
Source
npmnpm
Version
1.5.1
Version published
Maintainers
1
Created
Source

node-persistent-software

Spawn a software and keep it running

Build status Coverage status Dependency status Dev dependency status Issues Pull requests

Installation

$ npm install node-persistent-software

Doc (extends : asynchronous-eventemitter)

Attributes

  • maxCountRun: number max start iteration
  • successCountRun: 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 current
  • infinite() : this no max iteration and reset current
  • start() : this run the software for the first time
  • end() : 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 = require("node-persistent-software");

new PersistantSoftware("node", [ "-v" ]).on("error", (msg) => {
  console.log(msg);
})

.infinite()

.on("firststart", () => {
  console.log("node is started for the first time !");
}).on("restart", () => {
  console.log("node is started again...");
}).on("start", (child_process) => {
  console.log("anyway, node is started.");
})

.on("stop", () => {
  console.log("node is stopped, trying to restart...");
}).on("end", () => {
  console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();


new PersistantSoftware("node", [ "-v" ]).on("error", (err) => {
  console.log(err);
})

.max(5)

.on("firststart", () => {
  console.log("node is started for the first time !");
}).on("restart", () => {
  console.log("node is started again...");
}).on("start", () => {
  console.log("anyway, node is started.");
})

.on("stop", () => {
  console.log("node is stopped, trying to restart...");
}).on("end", () => {
  console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();

Typescript

import PersistantSoftware = require("node-persistent-software");

new PersistantSoftware("node", [ "-v" ]).on("error", (err) => {
  console.log(err);
})

.infinite();

Tests

$ npm run-script tests

License

ISC

Keywords

spawn

FAQs

Package last updated on 16 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts