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

batch-process

v0.1.0

Published

Node.js module for controlled batch processing, including log capture.

Downloads

2

Readme

batch-process - a Node.js module for controlling batch processes

This module executes external processes, capturing output and reporting on status.

Used by the seneca-run plugin to execute external processes.

Build Status

NPM NPM

If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger

Current Version: 0.1.0

Tested on: Node 0.10.31

Install

To install:

npm install batch-process

Quick Example

var batch_process = require('batch-process')

// define a batch process
// with common options
var batch = batch_process({
  command:'ls',
  args:['-lisa']
})

// create a new process with
// its own overridden options
var proc = batch.make_process({
  cwd:__dirname
})

// listen for the 'report' event
// errors are also reported this way
proc.on('report',function(rep){
  console.log(rep)

  if( rep.final ) {
    console.log('FINISHED')
  }
})

// actually execute the external process
proc.run()

Process Execution

Processes are run with child_process.spawn. The working directory is the current process directory, unless set explicitly via options (see below). Each process is given a unique indentifier in the format: name-timestamp-random.

The processes are not executed in a shell, so you must supply explicit arguments and full paths. You can provide environment variables with the env option.

The standard output and error are recorded and saved, both in-memory and to disk. The in-memory size is limited to a maximum (see options below). The disk recording is to /tmp by default. A new sub-folder is created each time, with files stdout and stderr containing their respective output.

Options

The options can be set at two levels. When defining a batch process with

var batch = batch_process({
  command:'ls',
  args:['-lisa']
})

And when running a process instance, with

var proc = batch.make_process({
  cwd:__dirname
})

The same options can be used at each level. Use the process options to override the common batch options to specialize the process execution.

The options are:

  • command: Process to execute. Use an absolute path if in doubt.
  • name: Name of batch process. For your own use. Default: command
  • args: Arguments for process. Default: []
  • cwd: Current working directory for process. Default: current.
  • env: Environment variables for process. Default: null
  • report_interval: Time between periodic emits of record event. If 0, then disabled.
  • timeout: Max time allowed for process to exit. For no limit, use 0. Default: 333333.
  • capture_size: Max in-memory size of output capture. Must be > 0. Default: 22222.
  • record_folder: Folder for output capture files. Default: '/tmp/batch_process'.
  • record: Record output flag. Default: true.
  • kill_signal: Signal sent to timedout process. Default: 'SIGTERM'.
  • uid: User id for process.
  • gid: Group id for process.

Testing

Unit tests use mocha, and can be run with:

npm test

Releases

  • 0.1.0: initial release