A job runner with support for asynchrony and dependencies.
A node.js-based job runner with support for asynchrony and dependencies.
First, install node.js.
Then, either install globally:
npm install -g jr
npm install jr
For command line use with a local installation, ensure node_modules/.bin is on your path.
JR can be used either as a command line tool or as a library.
> jr -hUsage: jr [options] <jobs>Options:-h, --help output usage information-V, --version output the version number-l, --list list jobs-t, --trace log trace messages
On the command line, JR reads a jobs.js file from the current directory, which is just a node module exporting a set of jobs:
moduleexports =job1:// call callback(null, results) or callback(error) when donejob2:needs: 'job1'// results.job1 contains the results from job1job3:needs: 'job1'// though needed by two jobs, job1 is only run once// job2 and job3 may run in paralleljob4:needs: 'job2' 'job3'// results contains the results of job1, job2, and job3job5:// not all jobs need to be connected;
Then, run (for example):
to run job4 and all the jobs it depends on.
In this case, job1 will be run, followed by job2 and job3 in parallel, and then job4. Job5 will not be run.
JR can also be used from within node:
var jr = require'jr';var jobs =config:callbacknull// config goes here;data:needs: 'config'// get some dataoutDir:needs: 'config'// setup output directoryoutFile:needs: 'config' 'data' 'outDir'// write data to output file in output directoryemailLink:needs: 'config' 'outFile'// send email containing link to output file;jrrunjobNames: 'emailLink'jobs: jobsif errconsole.logerr;;
Instead of a 'jobs' object, a path to a jobs file can be given:
var jr = require'jr';jrrunjobNames: 'build'jobsFile: 'scripts/build.js'if errconsole.logerr;elseconsole.log'success';;