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

batchdb-shell

v1.1.3

Published

job queue for shell scripts, writing output to blob storage

Downloads

16

Readme

batchdb-shell

job queue for shell scripts, writing output to blob storage

build status

example

queue a shell command

push a shell command onto the queue:

var batchdb = require('batchdb-shell');
var db = require('level')('/tmp/compute.db');

var compute = batchdb(db, { path: '/tmp/compute.blobs' });
var cmd = process.argv.slice(2).join(' ');
compute.add().end(cmd);

run a command

run the queued commands, one after the other:

var batchdb = require('batchdb-shell');
var db = require('level')('/tmp/compute.db');
var compute = batchdb(db, { path: '/tmp/compute.blobs' });

compute.on('result', function (key, id) {
    console.log('RESULT', id);
});

compute.run();

show a result

show the result of a command, printing colorized results for stderr and stdout:

var batchdb = require('batchdb-shell');
var colorize = require('ansi-color-stream');
var db = require('level')('/tmp/compute.db');
var compute = batchdb(db, { path: '/tmp/compute.blobs' });

var id = process.argv[2];
var p = compute.getOutput(id)

p.stdout.pipe(colorize('green')).pipe(process.stdout);
p.stderr.pipe(colorize('red')).pipe(process.stderr);

example output

$ node add.js date
$ node add.js 'date; uptime'
$ node add.js 'blah'
$ node run.js 
RESULT f15843b6c84fc23bd48623dc259968e759dd6bc0b84e69dd504d89f34f59e261
RESULT 82d7fce3b92dae949e8cd5b963c7bbf0948fa04a71b0752eed4fa1dae12a0726
RESULT 011a9bed9ed841dbc2be80244322904cd86a5f83ef15f1489f5acc9be416a8c1
$ node show.js f15843b6c84fc23bd48623dc259968e759dd6bc0b84e69dd504d89f34f59e261
Fri Sep  5 00:35:56 PDT 2014
$ node show.js 82d7fce3b92dae949e8cd5b963c7bbf0948fa04a71b0752eed4fa1dae12a0726
Fri Sep  5 00:35:56 PDT 2014
 00:35:56 up 2 days,  9:35,  8 users,  load average: 1.41, 1.13, 1.05
$ node show.js 011a9bed9ed841dbc2be80244322904cd86a5f83ef15f1489f5acc9be416a8c1
/bin/bash: line 1: blah: command not found

methods

var batchdb = require('batchdb-shell')

var compute = batchdb(db, opts)

Return a compute instance with all the methods from batchdb plus the extra ones documented here.

The jobs will be spawned in opts.shell, which defaults to the $SHELL environment variable or 'cmd' on windows and 'sh' everywhere else.

The stderr and stdout of spawned processes are packed by multiplex and can be unpacked again with compute.getOutput().

Just like batchdb, you can pass in a custom opts.store.

var sh = compute.getOutput(key)

Return an object sh with stdout and stderr readable stream properties from the results of the result identified by the result key key.

This is similar to compute.getResult(key), but with decoded channels.

sh.exitCode(function (code) {})

Read the exit code from the output result.

events

sh.on('exit', function (code) {})

The recorded exit code is saved and emitted on an 'exit' event.

install

With npm do:

npm install batchdb-shell

license

MIT