Skip to content

Commit beb6eb9

Browse files
committed
1 parent a31b5d7 commit beb6eb9

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

bin/dropstack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ program
2525
.version(`${pkg.name} v${pkg.version}`)
2626
.command('login <url>', 'Log-in or switch to deployment environment. (default https://api.cloud.dropstack.run)')
2727
.command('logout', 'Log-out from deployment environment.')
28-
.command('account', 'Show account informations.')
28+
.command('account', 'Show account informations.').alias('info')
2929
.command('activities', 'Show account activities.').alias('activity')
3030
.command('deploy [folder]', 'Deploy to environment.').alias('add')
3131
.command('list', 'List your active environment deployments.').alias('ls')
3232
.command('remove [name]', 'Remove deployment from environment.').alias('rm')
3333
.command('ssl [name]', 'Manage SSL for deployments.')
3434
.command('domain [name]', 'Manage domain for deployments.').alias('alias')
3535
.command('logs [name]', 'Show StdOut/StdErr logs for deployment.').alias('log')
36-
.command('metric [name]', 'Show metrics for deployments.')
36+
.command('metric [name]', 'Show metrics for deployments.').alias('metrics')
3737
.command('scale [name]', 'Scale instances for deployments.')
3838
.parse(process.argv);

bin/dropstack-logs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ function log({name, follow}) {
2323
.then(settings => {
2424
process.stderr.write('\x1B[?25l'); //hide terminal cursor
2525
const es = new EventSource(`${settings.url}/deploys/${name || settings.serviceName}/logs?${!follow ? 'follow='+follow : 'follow=true'}`, {headers: {connection: 'keep-alive', 'cache-control': 'no-cache', authorization: `Bearer ${settings.token}`}});
26+
process.stdout.write(chalk.gray(`Connecting...`));
27+
28+
es.onopen = () => {
29+
process.stdout.cursorTo(0);
30+
process.stdout.clearLine();
31+
process.stdout.write(`${chalk.green('Connected!')} ${chalk.gray('Receiving data ...')}`);
32+
};
33+
2634
es.onerror = () => {
2735
process.stderr.write('\x1B[?25h'); //show terminal cursor
2836
console.error('Log-Stream error occurred. Retry...');

bin/dropstack-metric

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ function metrics({name, live}){
2626
.then(response => response.json()))
2727
.then(data => Boolean(data.message) ? Promise.reject(new Error(data.message)) : data)
2828
.then(data => {
29-
console.log(chalk.gray(`| SUMMARY | Bytes in: ${data.inBytes || 0} | Bytes out: ${data.outBytes || 0} |`));
29+
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`));
30+
3031
Object.keys(data.services)
3132
.map(x => data.services[x])
32-
.forEach(x => console.log(chalk.gray(`| ${x.name} | Bytes in: ${x.inBytes || 0} | Bytes out: ${x.outBytes || 0} |`)));
33+
.filter(x => name ? x.name === name : true)
34+
.forEach(x => console.log(chalk.gray(`${chalk.green(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`, ' ')}`)));
3335
})
3436
.catch(err => {
3537
process.stderr.write('\x1B[?25h'); //show terminal cursor
@@ -77,22 +79,24 @@ function metricsLive(name){
7779
} catch(e){};
7880
if(!data.services) return;
7981

80-
const allMethodsCount = methodCounts(data.methods);
81-
process.stdout.clearLine();
8282
process.stdout.cursorTo(0);
83-
console.log(chalk.green(`Requests: ${allMethodsCount} Incoming: ${(data.inBytes / (1024 * 1024)).toFixed(2) || 0} MB Outgoing: ${(data.outBytes / (1024 * 1024)).toFixed(2) || 0} MB`));
84-
const services = Object.keys(data.services).map(x => data.services[x]);
83+
process.stdout.clearLine();
84+
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`));
85+
86+
const services = Object.keys(data.services).map(x => data.services[x]).filter(x => name ? x.name === name : true);
8587
services
8688
.forEach(x => {
8789
process.stdout.cursorTo(0);
8890
process.stdout.clearLine();
89-
console.log(chalk.gray(`| ${x.name} | Bytes in: ${x.inBytes || 0} | Bytes out: ${x.outBytes || 0} |`));
90-
91+
console.log(chalk.gray(`${chalk.green(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`, ' ')}`));
9192
});
92-
process.stdout.moveCursor(0, (services.length+1)*-1);
93+
process.stdout.moveCursor(0, (services.length+2) * -1);
9394
};
9495

95-
es.onerror = () => console.log(chalk.red('\nSorry, unexpected server communication error. Retry later please!'));
96+
es.onerror = () => {
97+
process.stderr.write('\x1B[?25h'); //show terminal cursor
98+
console.log(chalk.red('\nSorry, unexpected server communication error. Retry later please!'));
99+
};
96100
})
97101
.catch(err => {
98102
process.stderr.write('\x1B[?25h'); //show terminal cursor
@@ -117,8 +121,8 @@ function metricsLive(name){
117121
process.exit(1);
118122
}
119123

120-
if(err.message === 'Server communication error') {
121-
console.error(chalk.red(`\nSorry, server communication error occured. Retry later please!`))
124+
if(err.message === 'Unexpected server communication error') {
125+
console.error(chalk.red(`\nSorry, unexpected server communication error. Retry later please!`))
122126
return process.exit(1);
123127
}
124128

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.2",
3+
"version": "2.4.3",
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)