This is a simple module for interact with redis for hipache writen in nodejs. It can be used in nodejs or command-line.
It was inspired in prologic/hipachectl writen in python.
npm install --save hipachectl
All methods return a promisse and uses a client of redis nodejs to configure the redis connection.
var redis = require('redis'),
client = redis.createClient(),
hipache = new (require('hipachectl'))(client);
hipache
.add('myfrontend.com', '127.0.0.1:3000')
.then(function (added) {
console.log('Added', added);
return hipache.find('myfrontend.com');
})
.then(function (backends) {
console.log('Backends', backends);
});
This print
Added [ 'http://127.0.0.1:3000' ]
Backends [ 'myfrontend.com', 'http://127.0.0.1:3000' ]
When called, this ensures that a identifier will be created and will not insert the same backend twice. The identifier is the inserted frontend.
hipache
.add('myfrontend.com', '127.0.0.1:3000', '127.0.0.1:8080')
.then(function(backends){
console.log(backends);
});
Prints an array with the formatted backends that were entered.
[ 'http://127.0.0.1:3000', 'http://127.0.0.1:8080' ]
$ hipachectl add myfrontend.com 127.0.0.1:3000
Usage: hipachectl [options] [command]
Commands:
find <frontend> [backend...] Find a frontend or a backends inside a frontend
add <frontend> <backend...> Creates the frontend and associates a backends
remove <frontend> [backend...] Remove the frontend or a backends inside a frontend
rename <frontend> <newFrontend> Rename a frontend
formatBackend <backend> Format backend
formatFrontend <frontend> Format frontend
Options:
-h, --help output usage information
-V, --version output the version number
-u, --url <url> Redis URL for Hipache (default: 127.0.0.1:6379)
-s, --socket <socket> Redis socket for Hipache (overrides url)
This module was developed using docker-compose. You can run with node012 or node010
docker-compose run node012 npm install
docker-compose run node012 npm run watch
MIT

