From 2063a1e048814784f74d19233c3b94a44f82edc6 Mon Sep 17 00:00:00 2001 From: William Yeung Date: Sat, 15 Jul 2017 14:24:20 +0800 Subject: [PATCH 1/2] added support for state change for backend server --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 670f448..e65c36a 100644 --- a/index.js +++ b/index.js @@ -290,6 +290,18 @@ HAProxy.prototype.enable = function enable(backend, server, fn) { return this.send('enable server %s/%s', backend, server).call(fn); }; +/** + * Set the server attribute + * + * @param {String} backend Name of the backend server. + * @param {String} server The server that needs to be disabled in the backend. + * @param {Function} fn Callback. + * @api public + */ +HAProxy.prototype.state = function state(backend, server, newState, fn) { + return this.send('set server %s/%s state %s', backend || '', server || '', newState || '').call(fn); +}; + /** * Mark the frontend as temporarilty stopped. This corresponds to the mode which * is used during a soft restart. THe frontend releases the port but it can be From e749fda528d4ec0ecb746d7e855562d9afc41f15 Mon Sep 17 00:00:00 2001 From: William Yeung Date: Sat, 15 Jul 2017 14:27:07 +0800 Subject: [PATCH 2/2] updated method comments --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e65c36a..8a54aaa 100644 --- a/index.js +++ b/index.js @@ -291,10 +291,11 @@ HAProxy.prototype.enable = function enable(backend, server, fn) { }; /** - * Set the server attribute + * Set the server state to [ ready / maint / drain ] * * @param {String} backend Name of the backend server. * @param {String} server The server that needs to be disabled in the backend. + * @param {String} newState new state for the server [ ready / maint / drain ] * @param {Function} fn Callback. * @api public */