Ai
10 Star 47 Fork 10

10km/webredis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.js 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
10km 提交于 2019-04-21 17:10 +08:00 . 默认端口改为16379
/**
* 运行配置参数
* @author guyadong
*/
const yargs = require('yargs');
const sprintf = require('sprintf-js').sprintf
// 命令参数定义
let argv = yargs
.option('help' ,{alias : 'h',boolean : true, describe : 'show the messae' })
.option('port' ,{alias : 'p',default : '16379', describe : 'webredis web port'})
.option('rhost',{default : 'localhost',describe : 'redis host'})
.option('rport',{default : 6379, describe : 'redis port'})
.option('rauth',{default : '',describe : 'redis password'})
.option('rdb' ,{default : 0,describe : 'redis database'})
.option('rurl' ,{describe : 'redis url,ingnore other redis params if present'})
.usage('Usage: node.js webredis.js [OPTION...] ')
.argv;
if(argv.help){
// 输出帮助信息后退出
yargs.help()
.exit()
}
// node.js服务端口
var PORT = argv.port;
// redis 访问地址
if(argv.rurl){
var REDIS_URL = argv.rurl
}else{
var REDIS_URL = sprintf('redis://%s%s:%s/%d',argv.rauth.length==0?'':':'+argv.rauth +'@', argv.rhost , argv.rport ,argv.rdb)
}
module.exports.PORT = PORT
module.exports.REDIS_URL = REDIS_URL
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/l0km/webredis.git
git@gitee.com:l0km/webredis.git
l0km
webredis
webredis
master

搜索帮助