From ad8ebc2ba5bd7a383d0dd60a8f61947f6c45c9d1 Mon Sep 17 00:00:00 2001 From: youkunhuang Date: Thu, 24 May 2018 11:53:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4windows=E4=B8=8B=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=80=BB=E8=BE=91=EF=BC=8C=E5=8E=BB=E6=8E=89=E6=8E=A2?= =?UTF-8?q?=E6=B5=8B=E8=AF=B7=E6=B1=82=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/proxy/http.proxy.js | 71 +++++++---------------------------------- bin/proxy/master.js | 2 +- 2 files changed, 12 insertions(+), 61 deletions(-) diff --git a/bin/proxy/http.proxy.js b/bin/proxy/http.proxy.js index 0f31d5c4..a3943f06 100644 --- a/bin/proxy/http.proxy.js +++ b/bin/proxy/http.proxy.js @@ -22,7 +22,6 @@ const cp = require('child_process'); const parseGet = require('util/http/parseGet.js'); const tnm2 = require('api/tnm2'); const cpuUtil = require('util/cpu.js'); -const httpUtil = require('util/http.js'); const TEReport = require('util/auto-report/TEReport.js'); const mail = require('util/mail/mail.js'); const websocket = require('./websocket.js'); @@ -35,14 +34,14 @@ const serverInfo = { intranetIp: require('serverInfo.js').intranetIp, cpu: 'X' }; -var server; -var serverThis; -var serverHttps; -var config = require('./config.js'); -var routeCache = null; -var cleanCacheTid = null; -var isStartHeartBeat = false; -var heartBeatCount = 0; +let server; +let serverThis; +let serverHttps; +let config = require('./config.js'); +let routeCache = null; +let cleanCacheTid = null; +let isStartHeartBeat = false; +let heartBeatCount = 0; function doRoute(req,res){ @@ -52,57 +51,12 @@ function doRoute(req,res){ config = require('./config.js'); } - if(req.headers['user-agent'] === 'nws' && req.headers.host === serverInfo.intranetIp){ - //nws探测请求 - res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'}); - res.end('hello nws'); - - return; - } - - if(req.headers['user-agent'] === 'TgwProbe'){ - //stgw探测请求 - res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'}); - res.end('hello TgwProbe'); - - return; - } - - if(req.headers['user-agent'] === 'StgwProbe'){ - //stgw探测请求 - res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'}); - res.end('hello StgwProbe'); - - return; - } - - if(req.headers['user-agent'] === 'TgwProbe'){ - //stgw探测请求 - res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'}); - res.end('hello TgwProbe'); - - return; - } - - if(req.REQUEST.pathname === '/' && !req.headers['user-agent']){ - - if(httpUtil.isInnerIP(httpUtil.getUserIp(req))){ - //l7探测请求 - res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'}); - res.end('hello l7'); - return; - } - - } - routeCache(req,res); } process.serverInfo = serverInfo; -/** - * 清除缓存 - */ +//清除缓存 function cleanCache(){ clearTimeout(cleanCacheTid); @@ -127,7 +81,7 @@ process.on('heapdump',function(e){ require('heapdump').writeSnapshot(__dirname + '/cpu' + serverInfo.cpu + '.' + Date.now() + '.heapsnapshot',function(err, filename) { logger.info('dump written to ${filename}', { - filename: filename + filenamelet: filename }); }); @@ -540,10 +494,7 @@ methodMap.listen = function(message){ }; if(cluster.isMaster){ - if(isWindows){ - logger.info('isWindows, start listening'); - methodMap.listen({cpu : 0}); - }else if(debugOptions && debugOptions.inspectorEnabled){ + if(debugOptions && debugOptions.inspectorEnabled){ logger.setLogLevel('debug'); logger.info('inspectorEnabled, start listening'); methodMap.listen({cpu : 0}); diff --git a/bin/proxy/master.js b/bin/proxy/master.js index ed86946e..f764081b 100644 --- a/bin/proxy/master.js +++ b/bin/proxy/master.js @@ -315,7 +315,7 @@ function startServer(){ }else{ - //子进程直接引入proxy文件,当然也可以直接在这里写逻辑运行,注意此处else作用域属于子进程作用域,非本程序作用域 + //子进程直接引入proxy文件,注意此处else作用域属于子进程作用域,非本程序作用域 process.title = 'TSW/worker/node'; logger.info('start worker....'); require('./http.proxy.js');