npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

process-rerun

v0.4.4

Published

The purpose of this library is - build simple and flexible interface for parallel command execution with rerun (on fail) possibility

Downloads

12,992

Readme

process-rerun

The purpose of this library is - build simple and flexible interface for parallel command execution with rerun (on fail) possibility

npm downloads

Documents Usage getFilesList Changelog

Documents

buildRunner(buildOpts): returns rerunner: function(string[]): {retriable: string[]; notRetriable: string[]}

arguments | description --- | --- buildOpts | Type: object Options for executor buildOpts.maxThreads | Optional Type: number, How many threads can be executed in same time Default threads count is 5 buildOpts.intime | Optional Type: boolean, if intime is true intime execution approach will be enabled Default is false buildOpts.shuffle | Optional Type: boolean, Shuffle commands during execution Default threads count is 5 buildOpts.attemptsCount | Optional Type: number, How many times can we try to execute command for success result in next cycle will be executed only faild command, success commands will not be reexecuted Default attempts count is 2 buildOpts.pollTime | Optional Type: number, Period for recheck about free thread Default is 1 second buildOpts.successExitCode | Optional Type: number, Exit code what will be used for succes process check Default is 0 buildOpts.logLevel | Type: string, one of 'ERROR', 'WARN', 'INFO', 'VERBOSE', 'MUTE' ERROR - only errors, WARN - errors and warnings, INFO - errors, warnings and information, VERBOSE - full logging, MUTE - mute execution output Default is 'ERROR' buildOpts.currentExecutionVariable | Optional Type: string, will be execution variable with execution index for every cycle will be ++ buildOpts.everyCycleCallback | Optional Type: function, Optional. everyCycleCallback will be executed after cycle, before next execution cycle. Default is false buildOpts.processResultAnalyzer | Optional Type: function, Optional. processResultAnalyzer is a function where arguments are original command, execution stack trace and notRetriable array processResultAnalyzer should return a new command what will be executed in next cycle or boolean - if satisfactory result buildOpts.longestProcessTime | Optional Type: number, In case if command execution time is longer than longest Process Time - executor will kill it automatically and will try to execute this command again. Default time is 45 seconds

Usage

const {buildRunner} = require('process-rerun');

async function execCommands() {
  const runner = buildRunner({
    maxThreads: 10,               // ten threads
    attemptsCount: 2,             // will try to pass all commands two times, one main and one times rerun
    longestProcessTime: 60 * 1000,// if command process execution time is longre than 1 minute will kill it and try to pass in next cycle
    pollTime: 1000,               // will check free thread every second
    everyCycleCallback: () => console.log('Cycle done'),
    processResultAnalyzer: (cmd, stackTrace, notRetriableArr) => {
      if (stackTrace.includes('Should be re executed')) {
        return cmd;
      }
      notRetriableArr.push(cmd)
    }, //true - command will be reexecuted
  });
  const result = await runner([
    `node -e 'console.log("Success first")'`,
    `node -e 'console.log("Success second")'`,
    `node -e 'console.log("Failed first"); process.exit(1)'`,
    `node -e 'console.log("Success third")'`,
    `node -e 'console.log("Failed second"); process.exit(1)'`,
  ])

  console.log(result);
  /*
  {
    retriable: [
      `node -e 'console.log("Failed first"); process.exit(1)' --opt1=opt1value --opt1=opt1value`,
      `node -e 'console.log("Failed second"); process.exit(1)' --opt1=opt1value --opt1=opt1value`
    ],
    notRetriable: []
  }
  */
}

getfileslist

arguments | description --- | --- dir | Type: string , required Directory what will be used as a root fileList | Type: Array<string> , This array will be used as a target for push new file directoryToSkip | Type: Array<string>|string|regex, Exlude some directory ignoreSubDirs | Type: boolean, In case of true - sub directories will be ignored

usage exampele

const {getFilesList} = require('process-rerun');

const readmePath = getFilesList(__dirname).find((filePath) => filePath.include('readme.md'));

intime approach vs circle approach

circle approach

five processes execution, two execution attempts, five parallel execution

first execution attempt (three failed) | second execution attempt (one failed) | third execution attempt (o failed) --- | --- | ---- 1 p1 --------------------------> success | p2 ---> success | p4 -----------> success 2 p2 ---> fail | p4 -----------> fail | 3 p3 -------> fail | p3 -------> success | 4 p4 -----------> fail | | 5 p5 -----> success | |

Full execution time: p1 (first attempt) --------------------------> + p4 (second attempt) -----------> + (third attempt) p4 ----------->

intime approach (with same fail scheme)

every process has attemp count timer

f - fail s - success 1 p1 -------------------------->s 2 p2 --->f--->s 3 p3 ------->f------->s 4 p4 ----------->f 5 p5 ----->s(p4)----------->f----------->s

Full execution time:

5 p5 ----->s(p4)----------->f----------->s

Failed process will check that free parallel exists and start execution when free parallel will be found.

Changelog

Version 0.1.11