zhike-consul
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "zhike-consul", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "a simple consul client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ # zhike-consul | ||
const Consul = require('zhike-consul'); | ||
const configKeys = ['optimus', 'db', 'redis', 'mq']; | ||
const configKeys = ['order', 'mq', 'userService', 'payService']; | ||
const host = '127.0.0.1'; | ||
@@ -18,8 +18,14 @@ const port = 8500; | ||
consul.pull().then(function() { | ||
// 3.启动HTTP Server | ||
// 3.构造全局config对象 | ||
global.config = Object.assign({}, | ||
CFG.order, | ||
{mq: CFG.mq}, | ||
{userService: CFG.userService}, | ||
{payService: CFG.payService} | ||
); | ||
// 4.启动HTTP Server | ||
let express = require('express'); | ||
let app = express(); | ||
initRedis(CFG.redis.host, CFG.redis.port); | ||
initDB(CFG.optimus.db); | ||
app.listen(CFG.optimus.port); | ||
let mq = amqplib.connect('amqp://' + config.mq.user + ':' + config.mq.pass + '@' + config.mq.host + ':' + config.mq.port); | ||
app.listen(config.port); | ||
}) | ||
@@ -26,0 +32,0 @@ ``` |
4937
84