ddconsul
dianda simple consul client based on node-consul
usage
npm install ddconsul --save
var ddconsul = require('ddconsul');
var consul = new ddconsul();
consul.pull().then(function(config){
// ...
})
说明
new ddconsul(options)
- options
- options.host consul host,默认process.env.consulHost
- options.port consul port,默认process.env.consulPort
- options.ref 挂载config的对象,默认global
- options.timeout 连接consul服务的超时时间,默认2000ms
consul.pull(options)
- options
- options.env 指定运行环境,默认当前环境
-
options.appName 指定系统名称,默认取
package.json
中的name
-
options.localPath 本地配置文件目录,默认
/path/to/project/config
-
options.localFile 本地配置文件名称,默认
config.local.json
注意
本地开发最好配置一下环境变量,设置开发环境的consul地址
# 添加环境变量,zsh配置 ~/.zshrc
export consulHost=""
export consulPort=8500
export CLIENT_NAME='dianda'
source ~/.zshrc