沈斌
2017-08-11 cd83ef88f783205bc17d06b249fa62f9425957c6
测试-不要频繁增加连接数
1 files modified
26 ■■■■ changed files
server.js 26 ●●●● patch | view | raw | blame | history
server.js
@@ -113,13 +113,8 @@
    }
}
mongoClient.connect(config.URL, function(err, db) {
    if (err) {
        console.log(err.message);
        return;
    }
    console.log('Connecting to Mongo DB at ' + config.URL);
function doTCPSocket(db) {
    //初始化三级警报通讯方式
    method.initConfigs(db);
@@ -163,4 +158,23 @@
    }).listen(config.PORT, config.HOST);
    
    console.log('TCP Server listening on ' + config.HOST + ':' + config.PORT);
}
var db;
if(db == null) {
    mongoClient.connect(config.URL, function(err, database) {
        if (err) {
            console.log(err.message);
            return;
        }
        console.log('Connecting to Mongo DB at ' + config.URL);
        db = database;
        doTCPSocket(db);
});
} else {
    console.log('==========*****==========');
    doTCPSocket(db);
}