MXS-620: Add start/stop maxscale to MaxCtrl
The commands allow all services in MaxScale to be either stopped or started.
This commit is contained in:
parent
ae5260bec7
commit
cbe58b5355
@ -174,6 +174,10 @@ module.exports = function() {
|
||||
return base + argv.user + ':' + argv.password + '@' + host + '/v1/' + endpoint
|
||||
}
|
||||
|
||||
this.OK = function() {
|
||||
return Promise.resolve(colors.green('OK'))
|
||||
}
|
||||
|
||||
// Helper for executing requests and handling their responses, returns a
|
||||
// promise that is fulfilled when all requests successfully complete. The
|
||||
// promise is rejected if any of the requests fails.
|
||||
@ -190,7 +194,7 @@ module.exports = function() {
|
||||
return cb(res)
|
||||
} else {
|
||||
// Request OK, no data or data is ignored
|
||||
return Promise.resolve(colors.green('OK'))
|
||||
return OK()
|
||||
}
|
||||
}, function(err) {
|
||||
if (err.response && err.response.body) {
|
||||
|
@ -27,6 +27,20 @@ exports.builder = function(yargs) {
|
||||
return doRequest(host, 'monitors/' + argv.name + '/start', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.command('maxscale', 'Start MaxScale by starting all services', {}, function(argv) {
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/', function(res) {
|
||||
var promises = []
|
||||
|
||||
res.data.forEach(function(i) {
|
||||
promises.push(doRequest(host, 'services/' + i.id + '/start', null, {method: 'PUT'}))
|
||||
})
|
||||
|
||||
return Promise.all(promises)
|
||||
.then(() => OK())
|
||||
})
|
||||
})
|
||||
})
|
||||
.usage('Usage: start <command>')
|
||||
.help()
|
||||
.command('*', 'the default command', {}, function(argv) {
|
||||
|
@ -27,6 +27,20 @@ exports.builder = function(yargs) {
|
||||
return doRequest(host, 'monitors/' + argv.name + '/stop', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.command('maxscale', 'Stop MaxScale by stopping all services', {}, function(argv) {
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/', function(res) {
|
||||
var promises = []
|
||||
|
||||
res.data.forEach(function(i) {
|
||||
promises.push(doRequest(host, 'services/' + i.id + '/stop', null, {method: 'PUT'}))
|
||||
})
|
||||
|
||||
return Promise.all(promises)
|
||||
.then(() => OK())
|
||||
})
|
||||
})
|
||||
})
|
||||
.usage('Usage: stop <command>')
|
||||
.help()
|
||||
.command('*', 'the default command', {}, function(argv) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user