`password` config

This commit is contained in:
Tjatse 2014-12-18 15:22:22 +08:00
parent df7cf5e929
commit 22a5d80522
2 changed files with 15 additions and 454 deletions

View File

@ -5,7 +5,8 @@ var commander = require('commander'),
chalk = require('chalk'),
_ = require('lodash'),
pkg = require('../package.json'),
Monitor = require('../lib/mon'),
Monitor = require('../lib/mon'),
crypto = require('crypto'),
interface = require('../web/index');
commander.version(pkg.version, '-v, --version')
@ -34,13 +35,13 @@ commander.command('start [port]')
});
// Configuration
var acceptKeys = ['pm2', 'refresh', 'manipulation'];
var acceptKeys = ['pm2', 'refresh', 'manipulation', 'password'];
function showConfigs(cmd, mon){
if(!mon){
mon = Monitor();
if (!mon) {
mon = Monitor();
}
var storage = mon._config.store, prints = '';
for(var k in storage){
for (var k in storage) {
prints += Array(15 - k.length).join(' ') + chalk.bold(k + ': ') + ' ' + chalk.blue(storage[k] + '\n');
}
console.log(prints);
@ -53,10 +54,17 @@ commander.command('config')
commander.command('set <key> <value>')
.description('set config by key-value pairs')
.action(function(key, value, cmd){
if(!~acceptKeys.indexOf(key)){
return console.log('key could only be one of below:', acceptKeys.map(function(m){ return '\n' + chalk.magenta(m)}).join(''));
if (!~acceptKeys.indexOf(key)) {
return console.log('key could only be one of below:', acceptKeys.map(function(m){
return '\n' + chalk.magenta(m)
}).join(''));
}
var mon = Monitor();
if (key == acceptKeys[acceptKeys.length - 1]) {
var md5 = crypto.createHash('md5');
md5.update(value);
value = md5.digest('hex');
}
mon.config(key, value);
showConfigs(cmd, mon);
});

View File

@ -1,447 +0,0 @@
html, body {
background-color: #000;
font-family: Consolas, Menlo, Monaco, monospace;
letter-spacing: 0.5px;
height: 100%;
-webkit-text-size-adjust: none;
}
.load {
background: url(/img/ajax-loading.gif) no-repeat center center;
width: 20px;
height: 20px;
display: block;
}
.spinner {
z-index: 9999;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -20px;
width: 100px;
height: 40px;
}
@-webkit-keyframes stretchdelay {
0%, 40%, 100% {
-webkit-transform: scaleY(0.4)
}
20% {
-webkit-transform: scaleY(1.0)
}
}
@-moz-keyframes stretchdelay {
0%, 40%, 100% {
-webkit-transform: scaleY(0.4)
}
20% {
-webkit-transform: scaleY(1.0)
}
}
@-o-keyframes stretchdelay {
0%, 40%, 100% {
-webkit-transform: scaleY(0.4)
}
20% {
-webkit-transform: scaleY(1.0)
}
}
@keyframes stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4);
-moz-transform: scaleY(0.4);
-o-transform: scaleY(0.4);
-webkit-transform: scaleY(0.4);
}
20% {
transform: scaleY(1.0);
-moz-transform: scaleY(1.0);
-o-transform: scaleY(1.0);
-webkit-transform: scaleY(1.0);
}
}
.spinner > div {
background-color: #f0f0f0;
height: 100%;
display: inline-block;
width: 8px;
-webkit-animation: stretchdelay 1.1s infinite ease-in-out;
-moz-animation: stretchdelay 1.1s infinite ease-in-out;
-o-animation: stretchdelay 1.1s infinite ease-in-out;
animation: stretchdelay 1.1s infinite ease-in-out;
}
.spinner > div:nth-child(1) {
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
-o-animation-delay: 0s;
animation-delay: 0s;
}
.spinner > div:nth-child(2) {
-webkit-animation-delay: 0.1s;
-moz-animation-delay: 0.1s;
-o-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.spinner > div:nth-child(3) {
-webkit-animation-delay: 0.2s;
-moz-animation-delay: 0.2s;
-o-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.spinner > div:nth-child(4) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
-o-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.spinner > div:nth-child(5) {
-webkit-animation-delay: 0.4s;
-moz-animation-delay: 0.4s;
-o-animation-delay: 0.4s;
animation-delay: 0.4s;
}
.polar_usage {
margin: 0 auto;
}
.polar_usage text {
text-anchor: middle;
font-size: 10px;
fill: #fff;
}
.repo {
width: 100px;
text-align: center;
position: absolute;
left: 50%;
top: 3px;
margin-left: -50px;
}
.repo a {
display: block;
color: #666;
}
.repo a:hover {
color: #fff;
}
.repo span {
display: block;
color: #888;
font-size: 10px;
}
.system_info {
width: 200px;
margin: 0 auto;
display: none;
}
.system_info dl * {
width: 95px;
height: 20px;
line-height: 20px;
display: inline-block;
margin: 0;
font-weight: normal;
}
.system_info dl dt {
padding-right: 5px;
text-align: right;
color: #fff;
}
.system_info dl dd {
text-align: left;
padding-left: 5px;
color: #ccc;
}
.procs-hint-container {
position: absolute;
bottom: -1px;
left: 50%;
margin-left: -50px;
width: 100px;
height: 50px;
background: #3b4163;
border-radius: 50px 50px 0 0;
box-shadow: 0 -2px 3px #272e44;
-moz-box-shadow: 0 -2px 3px #272e44;
-o-box-shadow: 0 -2px 3px #272e44;
}
.procs-hint-container div {
width: 100%;
line-height: 65px;
text-align: center;
font-size: 16px;
color: #8e99bb;
text-shadow: 1px 1px 1px #000;
}
.procs-hint-container div span {
color: #c1ccec;
}
.procs, .slimScrollDiv {
width: 720px;
margin: 0 auto;
}
.procs .proc-div {
height: 1px;
margin: 5px auto;
width: 95%;
background: -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0, #3b4163),
color-stop(0.3, rgb(255, 255, 255)),
color-stop(0.9, #3b4163));
background: -moz-linear-gradient(left, #3b4163, rgb(255, 255, 255), #3b4163);
background: -o-linear-gradient(left, #3b4163, rgb(255, 255, 255), #3b4163);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#3b4163, endColorstr=#fff, GradientType=1);
}
.procs .proc {
height: 50px;
position: relative;
left: 20px;
right: 20px;
}
.procs .proc-stop .proc-info {
opacity: 0.8;
}
.procs .proc .proc-col {
display: table-cell;
}
.procs .proc .proc-status {
text-align: center;
width: 50px;
height: 50px;
}
.procs .proc .proc-status i {
font-size: 16px;
top: -18px;
color: #5fe210;
}
.procs .proc-empty .proc-status i {
color: #fddf68
}
.procs .proc-stop .proc-status i {
color: #e98080;
}
.procs .proc .proc-info {
width: 600px;
}
.proc-info ul, .proc-info ul li {
list-style: none;
list-style-position: outside;
margin: 0;
padding: 0;
}
.proc-info > ul {
display: block;
height: 30px;
}
.proc-info > ul.proc-content {
height: 20px;
}
.proc-info ul.proc-title > li {
height: 30px;
line-height: 30px;
font-size: 16px;
color: #fff;
float: left;
}
.proc-info ul.proc-title li.proc-name {
color: #73cce5;
cursor: pointer;
margin: 0 4px 0 2px;
}
.proc-info ul.proc-title li.proc-alert {
color: #fff;
margin: 0 4px 0 2px;
}
.proc-info ul.proc-title li sup {
font-size: 10px;
color: #4b8698;
}
.proc-info ul.proc-title li.proc-ops {
width: 70px;
float: right;
text-align: right;
position: relative;
}
.proc-ops ul,
.proc-ops .load {
position: absolute;
right: 0;
top: 0;
}
.proc-ops ul li {
float: left;
padding: 0 2px;
}
.proc-ops ul li i {
font-size: 12px;
color: #fff;
cursor: pointer;
opacity: 0.7;
}
.proc-ops ul li i:hover {
opacity: 0.8;
}
.proc-ops ul li i:active {
opacity: 1;
}
.proc-info ul.proc-content {
height: 20px;
}
.proc-info ul.proc-content li {
color: #ccc;
height: 20px;
line-height: 20px;
font-size: 12px;
float: left;
text-align: left;
padding-left: 5px;
}
.proc-info ul.proc-content li.proc-file {
width: 300px;
padding-left: 0;
}
.proc-info ul.proc-content li.proc-mem {
color: #5cb85c;
width: 35px;
}
.proc-info ul.proc-content li.proc-restart {
color: #f0ad4e;
width: 30px;
}
.proc-info ul.proc-content li.proc-uptime {
color: #888;
float: right;
text-align: right;
width: 150px;
}
.proc-info ul.proc-content li.proc-mode {
width: 70px;
}
.proc-info ul.proc-content li.proc-mode span {
border-radius: 3px;
padding: 3px 5px;
}
.proc-info ul.proc-content li.proc-mode-fork span {
color: #fff;
background: #323332;
}
.proc-info ul.proc-content li.proc-mode-cluster span {
color: #fff;
background: #426dbe;
}
.proc-popup {
color: #555;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
#popup {
height: 330px;
width: 100%;
position: relative;
}
#popup .load {
background-image: url(/img/ajax-loading-invert.gif);
position: absolute;
left: 50%;
top: 50%;
margin-left: -10px;
margin-top: -10px;
}
#popup pre {
background: transparent;
border: 0;
border-radius: 0;
}
#popup .nav {
padding-left: 10px;
}
#popup .nav > li > a {
padding: 5px 15px;
}
#popup .nav > li:hover > a {
border-bottom: solid 1px #fff;
}
#popup .nav-tabs > li {
margin-bottom: -2px;
margin-right: 5px;
}
#log {
padding: 5px;
}
#log span {
font-size: 12px;
}
#log > span {
padding: 2px;
display: block;
}