1.0.2 • Published 7 years ago
hyperlapse v1.0.2
hyperlapse
Distributed process manager. Listens on a hypercore feed for JSON commands to execute on the host machine using psy.
CLI API
Usage:
$ hyperlapse <command> [options]
Commands:
listen <hypercore key> Listen for commands and print a log key
append <hypercore key> <command> Append commands onto a feed
list <hypercore key> Print the services on a machine
Process commands:
start <package-name@version> Boot up a service on the host machine
stop
remove
restart
Options:
-h, --help Print usage
-v, --version Print version
JS API
var hyperlapse = require('hyperlapse')
var normcore = require('normcore')
// the command feed usually lives remotely
var commandFeed = normcore('command-feed')
var commandKey = commandFeed.key.toString('hex')
var inFeed = normcore(commandKey)
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)
commandFeed.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
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"
}
API
agent = 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