Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Last active December 14, 2015 10:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliangruber/5071867 to your computer and use it in GitHub Desktop.
Save juliangruber/5071867 to your computer and use it in GitHub Desktop.
horst api

horst

Usage

Create a server that listens for hosts:

var horst = require('horst');
var hub = horst();

hub.on('ps', function (ps) {
  // meta object
  assert(ps.meta == 'foo');
  
  // stdin, stdout and stderr
  ps.stdin.write('hey');
  ps.stdout.pipe(process.stdout, { end : false });
  ps.stderr.pipe(process.stderr, { end : false });
  
  // events
  ps.on('exit', function (code) {});
  ps.on('close', function () {});
  ps.on('respawn', function () {});

  // misc
  ps.kill(signal);
  console.log(ps.pid);
});

hub.listen(7000);

And spawn a process from javascript

hub.spawn('node', ['index.js'], { meta : 'foo' });

or with the horst executable:

$ horst --hub=localhost:7000 --meta=foo -- node index.js

API

var hub = host()

hub.on('ps', fn(ps) {})

hub.listen(port)

hub.spawn(proc, args, opts)

CLI

$ host --help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment