/hyperlapse

Distributed process manager

Primary LanguageJavaScriptMIT LicenseMIT

hyperlapse stability

npm version build status test coverage downloads js-standard-style

Distributed process manager. Listens on a hypercore feed for ndjson commands to execute on the host machine using psy.

CLI API

  Usage:
    $ hyperlapse <command> [options]

  Commands:
    init                            Create a new hypercore in the current dir
    listen <hypercore-public-key>   Listen for commands and print a log key
    start <package-name@version>    Start a service on the host machine
    stop <name>                     Stop a service on the host machine
    remove <name>                   Remove a service on the host machine
    restart <name>                  Restart a service on the host machine
    list                            List all services on the host machine

  Options:
    -h, --help       Print usage
    -v, --version    Print version
    -n, --name       Provide an explicit name when starting a service
    -k, --key        Pass a hypercore directory, assumes cwd if not passed

  Examples:
    $ hyperlapse init
    $ hyperlapse listen <64 bit hypercore public key>
    $ hyperlapse start \
      hypercore-archiver-bot@^1.0.0 -n hypercore-archiver-bot \
      -- hypercore-archiver-bot --channel=#dat --port=8080
    $ hyperlapse list

JS API

var hyperlapse = require('hyperlapse')
var normcore = require('normcore')

var inFeed = normcore('in-feed')
var outFeed = normcore('out-feed')
hyperlapse(inFeed, outFeed)

outFeed.createReadStream().pipe(process.stdout)
var outKey = outFeed.key.toString('hex')
console.log('outFeed key is ' + outKey)

inFeed.append(JSON.stringify({
  type: 'start',
  name: 'hypercore-archiver-bot',
  source: 'hypercore-archiver-bot@1.1.3',
  command: 'hypercore-archiver-bot --channel=#dat --port=8000'
}) + '\n')

Process commands

Each command should be valid newline delimited json.

Start

Start a new process on the machine.

{
  "type": "start",
  "name": "what the process should be named on the machine",
  "source": "e.g. my-cool-service-on-npm@3.4.7",
  "env": {
    "a bunch": "of env vars"
  }
}

Stop

Stop a process on the machine

{
  "type": "stop",
  "name": "my-cool-process"
}

Restart

Restart a process on the machine

{
  "type": "restart",
  "name": "my-cool-process"
}

Remove

Remove a process on the machine

{
  "type": "remove",
  "name": "my-cool-process"
}

List

List all processes on the machine

{
  "type": "list"
}

API

hyperlapse(inFeed, outFeed)

Create a new agent that tails a hypercore. Reads commands from the inFeed and logs its output to the outFeed.

Installation

$ npm install hyperlapse

See Also

License

MIT