Skip to content

Commit

Permalink
style(all): use camelCase only
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun authored and RobinzZH committed May 31, 2018
1 parent f9c8333 commit 0ae40e0
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 83 deletions.
44 changes: 22 additions & 22 deletions bin/lib/api/notify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ this.SendMail = function(opt) {
opt = Deferred.extend({
'appKey': '',
'sysId': 0,
'EmailType': 1, // 邮件类型,可选值0(外部邮件),1(内部邮件),2(约会邮件)
'From': '', // 邮件发送人
'To': '', // 邮件接收人
'Title': '', // 邮件标题
'Content': '', // 邮件内容
'Priority': 0, // 邮件优先级,-1低优先级,0普通,1高优先级
'BodyFormat': 0, // 邮件格式,0 文本、1 Html

'CC': '', // 邮件抄送人
'Bcc': '', // 邮件密送人
'Location': '', // 当邮件为约会邮件时,约会地点
'Organizer': '', // 当邮件为约会邮件时,约会组织者
'StartTime': '', // 当邮件为约会邮件时,约会开始时间
'EndTime': '', // 当邮件为约会邮件时,约会结束时间
'emailType': 1, // 邮件类型,可选值0(外部邮件),1(内部邮件),2(约会邮件)
'from': '', // 邮件发送人
'to': '', // 邮件接收人
'title': '', // 邮件标题
'content': '', // 邮件内容
'priority': 0, // 邮件优先级,-1低优先级,0普通,1高优先级
'bodyFormat': 0, // 邮件格式,0 文本、1 Html

'cc': '', // 邮件抄送人
'bcc': '', // 邮件密送人
'location': '', // 当邮件为约会邮件时,约会地点
'organizer': '', // 当邮件为约会邮件时,约会组织者
'startTime': '', // 当邮件为约会邮件时,约会开始时间
'endTime': '', // 当邮件为约会邮件时,约会结束时间
'attachment': '' // 邮件附件的文件名以及文件的内容(在发送请求时,文件内容是二进制数据流的形式发送)
}, opt);

Expand All @@ -57,10 +57,10 @@ this.SendWeiXin = function(opt) {
opt = Deferred.extend({
'appKey': '',
'sysId': 0,
'MsgInfo': '', // 内容
'Priority': 0, // 优先级,-1低优先级,0普通,1高优先级
'Receiver': '', // 接收人,英文名,多人用英文分号分隔
'Sender': '' // 发送人
'msgInfo': '', // 内容
'priority': 0, // 优先级,-1低优先级,0普通,1高优先级
'receiver': '', // 接收人,英文名,多人用英文分号分隔
'sender': '' // 发送人
}, opt);

const defer = Deferred.create();
Expand All @@ -74,10 +74,10 @@ this.SendSMS = function(opt) {
opt = Deferred.extend({
'appKey': '',
'sysId': 0,
'MsgInfo': '', // 内容
'Priority': 0, // 优先级,-1低优先级,0普通,1高优先级
'Receiver': '', // 接收人,英文名,多人用英文分号分隔
'Sender': '' // 发送人
'msgInfo': '', // 内容
'priority': 0, // 优先级,-1低优先级,0普通,1高优先级
'receiver': '', // 接收人,英文名,多人用英文分号分隔
'sender': '' // 发送人
}, opt);

const defer = Deferred.create();
Expand Down
23 changes: 5 additions & 18 deletions bin/lib/util/mail/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ this.SendMail = function(key, group, second, oriOpt) {
const opt = Deferred.extend({}, oriOpt);
const data = {};
const now = new Date();
let prefix = '[runtime]';

if (isWindows.isWindows) {
return;
Expand All @@ -33,24 +32,12 @@ this.SendMail = function(key, group, second, oriOpt) {
return;
}

if (context.title) {
opt.Title = `[${context.title}]${opt.Title}`;
}

if (config.isTest) {
prefix += '[测试环境]';
} else {
if (opt.runtimeType) {
prefix += `[${opt.runtimeType}][考核]`;
}
}

opt.Title = prefix + opt.Title;

data.Title = opt.Title || '';
data.title = opt.title || '';
data.oriTitle = oriOpt.title || '';
data.ctxTitle = context.title || '';
data.isTest = ~~config.isTest;
data.Content = opt.Content || '';
data.MsgInfo = opt.MsgInfo || '';
data.content = opt.content || '';
data.msgInfo = opt.msgInfo || '';
data.intranetIp = serverInfo.intranetIp || '';
data.second = second || '';
data.idc = config.idc || '';
Expand Down
4 changes: 2 additions & 2 deletions bin/lib/util/mail/src/mail.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

</head>
<body>
<p><%=data.Content%></p>
<p><%=data.content%></p>
<p><strong>服务器IP:</strong> <%=data.intranetIp%></p>

<p><strong>进程名字:</strong> <%=tmpl.encodeHtml(data.processTitle)%></p>
Expand Down Expand Up @@ -57,7 +57,7 @@

var window = context.window || {};
%>
<%=data.MsgInfo%>
<%=data.msgInfo%>
<%='\r\n\r\n'%>
服务器IP:<%=data.intranetIp%><%='\r\n'%>
进程名字: <%=tmpl.encodeHtml(process.title)%><%='\r\n'%>
Expand Down
4 changes: 2 additions & 2 deletions bin/lib/util/mail/tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define(function(require, exports, module) {

const window = context.window || {};
__p.push('<html>\n<head>\n<meta charset="utf-8" />\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n<meta name="robots" content="none" />\n<meta name="format-detection" content="telephone=no" />\n<meta name="HandheldFriendly" content="True" />\n<meta name="MobileOptimized" content="320" />\n<meta name="viewport" content="width=320,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no" />\n<meta name="viewport" content="width=319.9,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no" media="(device-height: 568px)" />\n<meta name="x5-fast-scroller" content="disable" />\n\n<style>\np{\n line-height: 1.5;\n}\ncode{\n font-size: 12px;\n}\n</style>\n\n</head>\n<body>\n <p>');
_p(data.Content);
_p(data.content);
__p.push('</p>\n <p><strong>服务器IP:</strong> ');
_p(data.intranetIp);
__p.push('</p>\n\n <p><strong>进程名字:</strong> ');
Expand Down Expand Up @@ -65,7 +65,7 @@ define(function(require, exports, module) {


const window = context.window || {};
_p(data.MsgInfo);
_p(data.msgInfo);
_p('\r\n\r\n');
__p.push('服务器IP:');
_p(data.intranetIp);
Expand Down
14 changes: 7 additions & 7 deletions bin/proxy/http.proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,15 @@ function heartBeat() {
timeout: 5000
}, function(err, data, errData) { // eslint-disable-line handle-callback-err
const key = `cpu80.v4:${serverInfo.intranetIp}`;
let Content = `<strong>单核CPU${serverInfo.cpu}使用率为:${cpuUsed},超过80%, 最近5秒钟CPU Profiler见附件</strong>`;
let content = `<strong>单核CPU${serverInfo.cpu}使用率为:${cpuUsed},超过80%, 最近5秒钟CPU Profiler见附件</strong>`;
let str = '';

if (data) {
str = data;
str = str.replace(/</g, '&gt;');
str = str.replace(/\r\n|\r|\n/g, '<br>');

Content += '<p><strong>进程快照:</strong></p><pre style="font-size:12px">' + str + '</pre>';
content += '<p><strong>进程快照:</strong></p><pre style="font-size:12px">' + str + '</pre>';
}


Expand All @@ -433,11 +433,11 @@ function heartBeat() {
recordTime: 5000
}, result => {
mail.SendMail(key, 'js', 600, {
'To': config.mailTo,
'CC': owner,
'MsgInfo': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%',
'Title': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%',
'Content': Content,
'to': config.mailTo,
'cc': owner,
'msgInfo': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%',
'title': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%',
'content': content,
'attachment': result ? {
fileType: true,
dispositionType: 'attachment',
Expand Down
10 changes: 5 additions & 5 deletions bin/proxy/http.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module.exports = function(req, res) {
return;
}

if (errorIgnore[err || err.message] === 'ignore') {
if (err && err.message && errorIgnore[err.message] === 'ignore') {
logger.warn(err && err.stack);
return;
}
Expand Down Expand Up @@ -224,12 +224,12 @@ module.exports = function(req, res) {
}

const key = err.message;
const Content = `<p><strong>错误堆栈</strong></p><p><pre><code>${err.stack}</code></pre></p>`;
const content = `<p><strong>错误堆栈</strong></p><p><pre><code>${err.stack}</code></pre></p>`;
mail.SendMail(key, 'js', 600, {
'Title': key,
'title': key,
'runtimeType': 'Error',
'MsgInfo': err.stack || err.message,
'Content': Content
'msgInfo': err.stack || err.message,
'content': content
});
}
});
Expand Down
12 changes: 6 additions & 6 deletions bin/proxy/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ process.on('uncaughtException', function(e) {
process.on('warning', function(warning) {
const key = String(warning);
const errStr = warning && warning.stack || String(warning);
const Content = `<p><strong>错误堆栈</strong></p><p><pre><code>${errStr}</code></pre></p>`;
const content = `<p><strong>错误堆栈</strong></p><p><pre><code>${errStr}</code></pre></p>`;

logger.error(errStr);

setImmediate(function() {
require('util/mail/mail.js').SendMail(key, 'js', 600, {
'Title': key,
'title': key,
'runtimeType': 'warning',
'Content': Content
'content': content
});
});
});
Expand All @@ -52,17 +52,17 @@ process.on('warning', function(warning) {
process.on('unhandledRejection', (errorOrReason, currPromise) => {
const errStr = String(errorOrReason && errorOrReason.stack || JSON.stringify(errorOrReason));
const key = String(errorOrReason && errorOrReason.message);
const Content = `<p><strong>错误堆栈</strong></p><p><pre><code>${errStr}</code></pre></p>`;
const content = `<p><strong>错误堆栈</strong></p><p><pre><code>${errStr}</code></pre></p>`;

// 恢复上下文
if (currPromise && currPromise.domain) {
currPromise.domain.run(function() {
logger.error(`unhandledRejection reason: ${errStr}`);
setImmediate(function() {
require('util/mail/mail.js').SendMail(key, 'js', 600, {
'Title': key,
'title': key,
'runtimeType': 'unhandledRejection',
'Content': Content
'content': content
});
});
});
Expand Down
18 changes: 5 additions & 13 deletions bin/tsw/ajax/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,6 @@ Ajax.prototype.doRequest = function(opt) {
responseText,
buffer,
code;
let key,
Content;

this.removeAllListeners('close');
this.removeAllListeners('end');
Expand Down Expand Up @@ -1065,19 +1063,13 @@ Ajax.prototype.doRequest = function(opt) {
times: times
});

key = [window.request.headers.host, context.mod_act, parseErr.message].join(':');

Content = [
'<p><strong>错误堆栈</strong></p>',
'<p><pre><code>',
parseErr.stack,
'</code></pre></p>',
].join('');
const key = [window.request.headers.host, context.mod_act, parseErr.message].join(':');
const content = `<p><strong>错误堆栈</strong></p><p><pre><code>${parseErr.stack}</code></pre></p>`;

require('util/mail/mail.js').SendMail(key, 'js data', 1800, {
'Title': key,
'Content': Content,
'MsgInfo': '错误堆栈:\n' + parseErr.stack
'title': key,
'content': content,
'msgInfo': '错误堆栈:\n' + parseErr.stack
});

return;
Expand Down
16 changes: 8 additions & 8 deletions bin/tsw/runtime/CCFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ this.check = function(req, res) {
const userIp = httpUtil.getUserIp(req);
const userIp24 = httpUtil.getUserIp24(req);

let Content;
let content;

const info = {
userIp: userIp,
Expand Down Expand Up @@ -203,7 +203,7 @@ this.check = function(req, res) {
// 发现目标,发邮件
const key = `[AVG_TSW_IP_STD_X10]:${serverInfo.intranetIp}`;

Content = '';
content = '';

Object.keys(cache.ipCacheLast).forEach(function(ip, i) {

Expand All @@ -216,21 +216,21 @@ this.check = function(req, res) {
) {
num = String(cache.ipCacheLast[ip].list.length);
num = (num + 'XXXXXX').slice(0, 8).replace(/X/g, '&nbsp;');
Content += `<div style="font-size:12px;">${num}${ip}</div>`;
content += `<div style="font-size:12px;">${num}${ip}</div>`;
}
});

mail.SendMail(key, 'TSW', 3600, {
'To': config.mailTo,
'CC': config.mailCC,
'Title': `[IP聚集告警][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`,
'Content': '<p><strong>服务器IP:</strong>' + serverInfo.intranetIp + '</p>'
'to': config.mailTo,
'cc': config.mailCC,
'title': `[IP聚集告警][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`,
'content': '<p><strong>服务器IP:</strong>' + serverInfo.intranetIp + '</p>'
+ '<p><strong>IP聚集度:</strong>' + cache.ipCacheLast.StdX10 + '%</p>'
+ '<p><strong>告警阀值:</strong>' + CCIPLimit + '</p>'
+ '<p><strong>正常值:</strong>5-50</p>'
+ '<p><strong>检测耗时:</strong>' + parseInt((cache.ipCacheLast.end - cache.ipCacheLast.start) / 1000, 10) + 's</p>'
+ '<p><strong>证据列表:</strong></p>'
+ Content
+ content
});


Expand Down

0 comments on commit 0ae40e0

Please sign in to comment.