| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | |
| | |
| | | }).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); |
| | | } |