Skip to content

Instantly share code, notes, and snippets.

@JohnMcLear
Created February 16, 2021 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnMcLear/b6d6430cd20a0fee4e6261734d67c51e to your computer and use it in GitHub Desktop.
Save JohnMcLear/b6d6430cd20a0fee4e6261734d67c51e to your computer and use it in GitHub Desktop.
promisify haproxy npm module
'use strict';
const HAProxy = require('haproxy');
const haproxy = new HAProxy('/tmp/haproxy.sock');
const ha = (method) => {
return new Promise((resolve, reject) => {
haproxy[method]((err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
});
}
(async () => {
const running = await ha('running');
console.log(`running: ${running}`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment