Skip to content

Commit

Permalink
Merge pull request #45 from orcinustools/0.4.2
Browse files Browse the repository at this point in the history
Bump version to 0.4.2
  • Loading branch information
anak10thn authored Mar 19, 2020
2 parents 405c804 + 51fcb37 commit d76b468
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 4 deletions.
12 changes: 10 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var rm = require("./lib/rm");
var inspect = require("./lib/inspect");
var rollback = require("./lib/rollback");
var cluster = require("./lib/cluster");
var logs = require("./lib/logs");

/*module dashboard*/
var web = require("./server");
Expand All @@ -32,11 +33,12 @@ program
.option('rm','Remove all service')
.option('ls [all|orcinus file|service name]', 'List service')
.option('ps', 'List all process')
.option('scale [service_name=num_scale]', 'scale service')
.option('scale [service_name=num_scale]', 'Scale service')
.option('inspect', 'Inspect all service')
.option('update', 'Update service')
.option('rollback', 'Rollback service')
.option('dashboard', 'Start dashboard <hostname:port>')
.option('logs [follow|help|tail]', 'Get service logs')
.option('cluster [option|help]', 'Manage Cluster',/^(init|join|leave|leave-manager|ls|token|promote|inspect|option|--help|-h)$/i)
.parse(process.argv);

Expand All @@ -58,7 +60,7 @@ if(program.file){
//cliValidation();
}

if(!program.dashboard && !program.cluster && !program.ls && !program.scale){
if(!program.dashboard && !program.cluster && !program.ls && !program.scale && !program.logs){
if(!data){
var defaultManifest = "orcinus";
// Favor yaml over json
Expand Down Expand Up @@ -164,6 +166,12 @@ if(program.cluster){
cluster.start(cli,args);
}

if(program.logs){
var args = program.args;
var cli = program.logs;
logs.start(cli,args);
}

if(program.dashboard){
if(program.args.length > 0){
var environtment = program.args[0].split(":");
Expand Down
2 changes: 1 addition & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ module.exports = {
help : ()=>{
console.log("Usage: orcinus cluster COMMAND");
console.log("");
console.log("Manage Docker Swarm Cluster From Orcinus");
console.log("Manage Orcinus Cluster");
console.log("");
console.log("Commands:");
console.log(" info Print usage");
Expand Down
77 changes: 77 additions & 0 deletions lib/logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var utils = require("./utils");
var ps = require('process');
var chp = require('child_process');
var utf8 = require('utf8');
var fs = require('fs');
var home = utils.getUserHome() + "/.orcinus";
var arg;
var cmd = 'docker';
var cmd_token = ['service','logs']
module.exports = {
start: (cli, args) => {
arg = args;
if (typeof (cli) == 'string') {
switch (cli) {
case 'follow':
module.exports.follow(args);
break;
case 'tail':
module.exports.tail(args);
break;
default:
module.exports.init(cli)
break;
}
}
else {
module.exports.help();
}
},
init: (cli) => {
cmd_token.push(cli);
module.exports.ps(cmd,cmd_token);
},
follow: (args) => {
if(!args[0]){
module.exports.help();
}
else{
cmd_token.push('-f');
cmd_token.push(args[0]);
module.exports.ps(cmd,cmd_token);
}
},
tail: (args) => {
if(args.length > 0){
cmd_token.push('--tail');
if(args.length == 2){
cmd_token.push(args[0].toString());
cmd_token.push(args[1]);
}
else{
cmd_token.push('10');
cmd_token.push(args[1]);
}
module.exports.ps(cmd,cmd_token);
}
else{
module.exports.help();
}
},
help: () => {
console.log("Usage: orcinus logs [COMMAND] SERVICE_NAME");
console.log("");
console.log("Manage Orcinus logs service");
console.log("");
console.log("Commands:");
console.log(" follow Follow log output");
console.log(" tail [line] Number of lines to show from the end of the logs (default=10)");
ps.exit(0);
},
ps: (base, token)=>{
var child = chp.spawn(base,token);
child.stdout.on('data', (data) => {
process.stdout.write(`${data}`);
});
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orcinus",
"version": "0.4.1",
"version": "0.4.2",
"description": "Container orchestration tools",
"main": "cli.js",
"scripts": {
Expand Down

0 comments on commit d76b468

Please sign in to comment.