npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

singlerun

0.2.6 • Public • Published

singlerun

Make sure an instance of the currently running script is only instanced once.

singlerun(killother, includeparams, mainProc)

Runs the mainProc if killother is true and is not currently running a script with the same name.

Arguments

  • killother boolean that specifies what to do if the script is already running, if true it will send a kill segterm to the other proc.
  • includeparams boolean that tells singlerung to consider the arguments of the script as part of the search of a process already running, if false it will just consider the script name; i.e. myscript.js and myscript.js --help would be different if includeparams is true.

examples

singlerun = require("singlerun")
 
// run script and kill any other instance of same script witouth considering the parameters for uniqueness
singlerun(true, false, function(){
    console.log "hello planet!"
});
 
// run script if not already running considering the parameters of the script
singlerun(false, false, function(){
    console.log "hello planet!"
});

install

npm i singlerun

Downloadsweekly downloads

39

version

0.2.6

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
Report a vulnerability