Skip to content

Commit 225a0d0

Browse files
committed
Enhance metric informations
1 parent e166966 commit 225a0d0

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

bin/dropstack-deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function deployment(settings, verbose, token, url) {
237237
return resolve(settings);
238238
}
239239

240-
const progressMessage = progressState.buildImageProgress || progressState.deployProgress || progressState.pushImageProgress || '';
240+
const progressMessage = progressState.buildImageProgress || progressState.deployProgress || progressState.pushImageProgress || 'Processing';
241241
if(progressState && progressState.serviceName && verbose) {
242242
console.log(chalk.gray(`${progressState.serviceName} ${progressMessage} ${(progressState.log || '').replace('\n', '')}`))
243243
} else {

bin/dropstack-logs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const configuration = require('../lib/settings')();
88

99
program
1010
.arguments('[name]')
11-
.option('-f, --nofollow', 'Do not follow stream')
11+
.option('-f, --nofollow', 'Disable live updates.')
1212
.action(name => log({
1313
name: name,
1414
follow: !Boolean(program.nofollow),

bin/dropstack-metric

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const configuration = require('../lib/settings')();
99

1010
program
1111
.arguments('[name]')
12-
.option('-f, --nofollow', 'Do not follow stream')
13-
.option('-a, --all', 'Show online and offline deployments.')
12+
.option('-f, --nofollow', 'Disable live updates.')
13+
.option('-a, --all', 'Show all deployments.')
1414
.action(name => metricsLive({
1515
name: name,
1616
all: program.all,
@@ -30,13 +30,13 @@ function metrics({name, all}){
3030
.then(response => response.json()))
3131
.then(data => Boolean(data.message) ? Promise.reject(new Error(data.message)) : data)
3232
.then(data => {
33-
console.log(chalk.green(`Summary - ${pad(16, `Requests: ${methodCounts(data.methods)}`, ' ')} ${pad(20, `Incoming: ${(data.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(data.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}\n`));
33+
console.log(chalk.green(`Summary - ${pad(16, `Requests: ${methodCounts(data.methods)}`, ' ')} ${pad(20, `Incoming: ${(data.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(data.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}\n`));
3434

3535
Object.keys(data.services)
3636
.map(x => data.services[x])
3737
.filter(x => name ? x.name === name : true)
38-
.filter(x => !all ? x.active : true)
39-
.forEach(x => console.log(chalk.gray(`${x.active ? chalk.green('online ') : chalk.red('offline')} - ${x.active ? chalk.green(x.name) : chalk.gray(x.name)} - ${pad(16, `Requests: ${methodCounts(x.methods)}`, ' ')} ${pad(20, `Incoming: ${(x.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(x.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}`)));
38+
.filter(x => !all & !name ? x.active : true)
39+
.forEach(x => console.log(chalk.gray(`${x.active ? chalk.green('active ') : chalk.red('inactive')} - ${x.active ? chalk.green(x.name) : chalk.gray(x.name)} - ${pad(16, `Requests: ${methodCounts(x.methods)}`, ' ')} ${pad(20, `Incoming: ${(x.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(x.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}`)));
4040
})
4141
.catch(err => {
4242
process.stderr.write('\x1B[?25h'); //show terminal cursor
@@ -88,19 +88,20 @@ function metricsLive({name, all, nofollow}){
8888

8989
process.stdout.cursorTo(0);
9090
process.stdout.clearLine();
91-
console.log(chalk.green(`Summary - ${pad(16, `Requests: ${methodCounts(data.methods)}`, ' ')} ${pad(20, `Incoming: ${(data.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(data.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}\n`));
91+
console.log(chalk.green(`Summary - ${pad(16, `Requests: ${methodCounts(data.methods)}`, ' ')} ${pad(20, `Incoming: ${(data.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(data.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}\n`));
9292

9393
const services = Object.keys(data.services).map(x => data.services[x])
9494
.filter(x => name ? x.name === name : true)
95-
.filter(x => !all ? x.active : true);
95+
.filter(x => !all & !name ? x.active : true);
9696

9797
services
9898
.forEach(x => {
9999
process.stdout.cursorTo(0);
100100
process.stdout.clearLine();
101-
console.log(chalk.gray(`${x.active ? chalk.green('online ') : chalk.red('offline')} - ${x.active ? chalk.green(x.name) : chalk.gray(x.name)} - ${pad(16, `Requests: ${methodCounts(x.methods)}`, ' ')} ${pad(20, `Incoming: ${(x.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(x.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}`));
101+
console.log(chalk.gray(`${x.active ? chalk.green('active ') : chalk.red('inactive')} - ${x.active ? chalk.green(x.name) : chalk.gray(x.name)} - ${pad(16, `Requests: ${methodCounts(x.methods)}`, ' ')} ${pad(20, `Incoming: ${(x.inBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')} ${pad(20, `Outgoing: ${(x.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`, ' ')}`));
102102
});
103-
process.stdout.moveCursor(0, (services.length+2) * -1);
103+
104+
process.stdout.moveCursor(0, (services.length + 2) * -1);
104105
};
105106

106107
es.onerror = () => {

bin/dropstack-remove

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ function remove({name, force}){
106106
process.exit(1);
107107
}
108108

109+
if(err.message === `error: ${name} missing`) {
110+
console.error(chalk.red(`\nService not found. Already removed or wrong account? Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
111+
process.exit(1);
112+
}
113+
109114
console.error(chalk.red(`\nAn unexpected error occurred!\nError: ${chalk.gray(err.message)}`));
110115
process.exit(1);
111116
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dropstack-cli",
3-
"version": "2.4.6",
3+
"version": "2.4.7",
44
"description": "A CLI to simplify continuous deployments into hybrid clouds.",
55
"author": "Mike Bild <mike@codecommission.com>",
66
"homepage": "https://github.com/codecommission/dropstack-cli#readme",

0 commit comments

Comments
 (0)