0.1.1 • Published 10 years ago

seneca-run v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

seneca-run - a Seneca plugin

Seneca Run Plugin

This plugin runs and manages external processes. It maintains a table of named processes and process options.

The batch-process module is used to execute the external processes. Refer to that module for the options to use in the batch option below. Note that that module generates log files on disk, which you will need to cleanup periodically in production.

The status of running processes are provided via the role:run,info:report pattern, which you should implement using seneca.add.

Build Status

NPM NPM

For a gentle introduction to Seneca itself, see the senecajs.org site.

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

Current Version: 0.1.1

Tested on: Seneca 0.5.20, Node 0.10.31

Install

To install:

npm install seneca-run

Quick Example

var seneca = require('seneca')()
  .use('run',{
    batch:{
      'basic-ls':{
        command:'ls',
        args:['-lisa'],
        cwd:__dirname
      }
    }
  })

// subscribe to the reporting pattern
seneca.sub('role:run,info:report',function(args){
  if( 'basic-ls' == args.report.name ) {
    console.log(args.report)
  }
})
  
seneca.act('role:run,cmd:execute,name:basic-ls',console.log)

Usage

Define your batch processes as options to the plugin. Then call the pattern role:run,cmd:execute to run them. The result object contains a procid field which you can use to query the status of a process with the role:run,cmd:query,procid:? pattern.

To receive reports of the status as it runs, subscribe to the role:run,info:report pattern. This will give you reports of all running processes. To narrow it down to one process, include the name of the process in the pattern:

// see test/npm-all.js
seneca.sub('role:run,info:report,name:npm-all',function(args,done){
  console.log(args.report)
})

For usage in a micro-service context, see nodezoo-npm-all.

Options

The options are:

  • batch: Object. Keys are the names of processes. Values are options for batch-process.

Testing

Unit tests use mocha, and can be run with:

npm test

For detailed logging, use:

SENECA_LOG=all npm test

Releases

  • 0.1.0: initial release