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:
@ -174,6 +174,10 @@ module.exports = function() {
|
|||||||
return base + argv.user + ':' + argv.password + '@' + host + '/v1/' + endpoint
|
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
|
// Helper for executing requests and handling their responses, returns a
|
||||||
// promise that is fulfilled when all requests successfully complete. The
|
// promise that is fulfilled when all requests successfully complete. The
|
||||||
// promise is rejected if any of the requests fails.
|
// promise is rejected if any of the requests fails.
|
||||||
@ -190,7 +194,7 @@ module.exports = function() {
|
|||||||
return cb(res)
|
return cb(res)
|
||||||
} else {
|
} else {
|
||||||
// Request OK, no data or data is ignored
|
// Request OK, no data or data is ignored
|
||||||
return Promise.resolve(colors.green('OK'))
|
return OK()
|
||||||
}
|
}
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.response && err.response.body) {
|
if (err.response && err.response.body) {
|
||||||
|
|||||||
@ -27,6 +27,20 @@ exports.builder = function(yargs) {
|
|||||||
return doRequest(host, 'monitors/' + argv.name + '/start', null, {method: 'PUT'})
|
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>')
|
.usage('Usage: start <command>')
|
||||||
.help()
|
.help()
|
||||||
.command('*', 'the default command', {}, function(argv) {
|
.command('*', 'the default command', {}, function(argv) {
|
||||||
|
|||||||
@ -27,6 +27,20 @@ exports.builder = function(yargs) {
|
|||||||
return doRequest(host, 'monitors/' + argv.name + '/stop', null, {method: 'PUT'})
|
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>')
|
.usage('Usage: stop <command>')
|
||||||
.help()
|
.help()
|
||||||
.command('*', 'the default command', {}, function(argv) {
|
.command('*', 'the default command', {}, function(argv) {
|
||||||
|
|||||||
Reference in New Issue
Block a user