Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cfernandomaciel/33c366db0e40ce4646c325ff3cefd7a4 to your computer and use it in GitHub Desktop.
Save cfernandomaciel/33c366db0e40ce4646c325ff3cefd7a4 to your computer and use it in GitHub Desktop.
Consul-Node-POC.js
const Request = require('request-promise');
const NODE_NAME = 'socket-binance-apps';
const NODE_ADDRESS = '127.0.0.1';
const SERVICE_NAME = 'binance-BTCLTC';
const SERVICE_ID = require('uuid').v4();
const url = 'http://127.0.0.1:8500/v1/';
const port = 15000;
const tags = ['btcltc', 'socket', '15000'];
const path = 'catalog/register';
const body = {
Node: NODE_NAME,
Address: NODE_ADDRESS,
Service: {
Id: `${SERVICE_NAME}`,
Service: SERVICE_NAME,
Tags: tags,
Port: port
},
Check: {
Node: NODE_NAME,
CheckID: 'service:'+SERVICE_NAME+':1',
Name: 'service:'+SERVICE_NAME+':1',
Notes: 'ping test',
Output: 'holla, que tal?',
ServiceID: SERVICE_NAME,
ServiceName: SERVICE_NAME,
ServiceTags: tags,
Definition: {
TCP: NODE_ADDRESS+':'+port,
Interval: '5s',
Timeout: '30s'
}
}
}
// console.log(JSON.stringify(body, null, 1));
// const path = 'catalog/deregister';
// const body = {
// Node: NODE_NAME
// }
const options = {
uri: url + path,
method: 'PUT',
body,
json: true
};
Request(options)
.then((result) => {
console.log(result)
})
.catch((exception) => {
console.error(exception);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment