Created
February 16, 2021 17:43
-
-
Save JohnMcLear/b6d6430cd20a0fee4e6261734d67c51e to your computer and use it in GitHub Desktop.
promisify haproxy npm module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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