Skip to content

Commit

Permalink
Merge pull request #164 from Tencent/dev
Browse files Browse the repository at this point in the history
Release 1.1.5
  • Loading branch information
RobinzZH authored Jul 6, 2018
2 parents 8813ad1 + 3de60dc commit 285de00
Show file tree
Hide file tree
Showing 27 changed files with 528 additions and 172 deletions.
19 changes: 18 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,26 @@
],
"strict": [
"off"
],
"new-cap": [
"off"
]
},
"overrides": [
{
"files": ["bin/**/*Jce.js"],
"rules": {
"no-var": [
"off"
],
"no-unused-vars": [
"off"
],
"no-use-before-define": [
"off"
]
}
},
{
"files": ["bin/tsw/wwwroot/*.js"],
"env": {
Expand All @@ -131,7 +148,7 @@
]
}
}, {
"files": ["bin/lib/util/mail/tmpl.js", "bin/tsw/util/**/tmpl.js"],
"files": ["bin/**/tmpl.js"],
"rules": {
"no-unused-vars": [
"error",
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: node_js
node_js:
- "8"
- "9"
- "10.5.0"

script:
- commitlint-travis
Expand Down
13 changes: 6 additions & 7 deletions bin/proxy/http.proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ process.on('message', function(message) {
return;
}

logger.info(`cpu: ${serverInfo.cpu} ${message.cmd}`);
logger.info(`receive message, cmd: ${message.cmd}`);
methodMap[message.cmd](message);
});

Expand Down Expand Up @@ -251,8 +251,7 @@ function listen(cpu) {

const finish = function() {

// 开始发送心跳
logger.info('start heart beat');
logger.info('start heartbeat');

startHeartBeat();

Expand All @@ -268,11 +267,13 @@ function listen(cpu) {
uid: user_00
});
}

websocket.start_listen();

logger.info('cpu: ${cpu}, afterStartup...', serverInfo);

if (typeof config.afterStartup === 'function') {
logger.info('cpu: ${cpu}, config.afterStartup fired', serverInfo);
config.afterStartup(serverInfo.cpu);
}
};
Expand Down Expand Up @@ -356,18 +357,16 @@ function heartBeat() {
}

global.cpuUsed = cpuUtil.getCpuUsed(serverInfo.cpu);

if (global.cpuUsed >= 80) {
global.cpuUsed80 = ~~global.cpuUsed80 + 1;
} else {
global.cpuUsed80 = 0;
}

const cpuUsed = global.cpuUsed;
tnm2.Attr_API_Set('AVG_TSW_CPU_USED', cpuUsed);

// 高负载告警
if (global.cpuUsed80 === 4 && !config.isTest && !isWin32Like) {
afterCpu80(cpuUsed);
afterCpu80(global.cpuUsed);
}

const currMemory = process.memoryUsage();
Expand Down
7 changes: 5 additions & 2 deletions bin/proxy/http.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ function doRoute(req, res) {
};
})(res.writeHead);

const mod_act = contextMod.currentContext().mod_act || httpModAct.getModAct(req);
let mod_act = contextMod.currentContext().mod_act || httpModAct.getModAct(req);
if (typeof mod_act !== 'string' || !mod_act) {
mod_act = null;
}
contextMod.currentContext().mod_act = mod_act;

if (alpha.isAlpha(req)) {
Expand Down Expand Up @@ -606,7 +609,7 @@ function doRoute(req, res) {

dcapi.report({
key: 'EVENT_TSW_HTTP_IP_BLOCK',
toIp: clientIp || '127.0.0.1',
toIp: clientIp,
code: 0,
isFail: 0,
delay: 100
Expand Down
Loading

0 comments on commit 285de00

Please sign in to comment.