Skip to content

LCMApps/drover-express-router

Repository files navigation

node npm npm Travis (.org) Coverage Status

Drover express router plugin

Simple drover plugin for express that provides convenient drover control flow via HTTP

Installation

Using npm:

$ npm i --save drover-express-router

Using yarn:

$ yarn add drover-express-router

Usage

const { MasterFactory } = require('drover');

const app = require('express')();
const drover = require('drover-express-router');

const demo = MasterFactory.create({
  script: 'path/to/demo.js',
});

// one line to plug-in drover controls into your express app
app.use('/demo', drover({ master: demo }));

app.listen(3000);

API

Get status

curl -XGET localhost:3000/demo/status
//{"status": STATUS}

Get workers statuses

curl -XGET localhost:3000/demo/status/workers
//{"workers": [STATUS]}

Scale

curl -XPUT localhost:3000/demo/scale -d 'size=4'

Graceful shutdown

curl -XPUT localhost:3000/demo/shutdown

Start

curl -XPUT localhost:3000/demo/start

Graceful reload

curl -XPUT localhost:3000/demo/reload

Composite apps

If you got composite drover application with 2 or more masters you still can do this like this:

const { MasterFactory } = require('drover');

const app = require('express')();
const drover = require('drover-express-router');

const foo = MasterFactory.create({ script: 'path/to/foo.js' });
const bar = MasterFactory.create({ script: 'path/to/bar.js' });

app.use('/foo', drover({ master: foo }));
app.use('/bar', drover({ master: bar }));

app.listen(3000);

About

Express router plugin for Drover control interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published