Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
fa7ef01a
N
Nightingale
项目概览
jobily
/
Nightingale
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fa7ef01a
编写于
3月 25, 2020
作者:
U
ulricqin
提交者:
GitHub
3月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26 from wulorn/addRedisDB
增加redis配置项,可通过配置文件配置指定的redis库
上级
c54949cb
76fd7b38
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
0 deletion
+24
-0
etc/judge.yml
etc/judge.yml
+1
-0
etc/monapi.yml
etc/monapi.yml
+1
-0
src/modules/judge/backend/redi/redis.go
src/modules/judge/backend/redi/redis.go
+11
-0
src/modules/monapi/config/yaml.go
src/modules/monapi/config/yaml.go
+1
-0
src/modules/monapi/redisc/redis.go
src/modules/monapi/redisc/redis.go
+10
-0
未找到文件。
etc/judge.yml
浏览文件 @
fa7ef01a
...
...
@@ -6,6 +6,7 @@ query:
redis
:
addrs
:
-
127.0.0.1:6379
db
:
0
pass
:
"
"
# timeout:
# conn: 500
...
...
etc/monapi.yml
浏览文件 @
fa7ef01a
...
...
@@ -52,6 +52,7 @@ link:
# for alarm event and message queue
redis
:
addr
:
"
127.0.0.1:6379"
db
:
0
pass
:
"
"
# in ms
# timeout:
...
...
src/modules/judge/backend/redi/redis.go
浏览文件 @
fa7ef01a
...
...
@@ -15,6 +15,7 @@ var Config RedisSection
type
RedisSection
struct
{
Addrs
[]
string
`yaml:"addrs"`
Pass
string
`yaml:"pass"`
DB
int
`yaml:"db"`
Idle
int
`yaml:"idle"`
Timeout
TimeoutSection
`yaml:"timeout"`
Prefix
string
`yaml:"prefix"`
...
...
@@ -31,6 +32,7 @@ func Init(cfg RedisSection) {
addrs
:=
cfg
.
Addrs
pass
:=
cfg
.
Pass
db
:=
cfg
.
DB
maxIdle
:=
cfg
.
Idle
idleTimeout
:=
240
*
time
.
Second
...
...
@@ -59,6 +61,15 @@ func Init(cfg RedisSection) {
}
}
if
db
!=
0
{
if
_
,
err
:=
c
.
Do
(
"SELECT"
,
db
);
err
!=
nil
{
c
.
Close
()
logger
.
Error
(
"redis select db fail, db: "
,
db
)
stats
.
Counter
.
Set
(
"redis.conn.failed"
,
1
)
return
nil
,
err
}
}
return
c
,
err
},
TestOnBorrow
:
PingRedis
,
...
...
src/modules/monapi/config/yaml.go
浏览文件 @
fa7ef01a
...
...
@@ -43,6 +43,7 @@ type cleanerSection struct {
type
redisSection
struct
{
Addr
string
`yaml:"addr"`
Pass
string
`yaml:"pass"`
DB
int
`yaml:"db"`
Idle
int
`yaml:"idle"`
Timeout
timeoutSection
`yaml:"timeout"`
}
...
...
src/modules/monapi/redisc/redis.go
浏览文件 @
fa7ef01a
...
...
@@ -17,6 +17,7 @@ func InitRedis() {
addr
:=
cfg
.
Redis
.
Addr
pass
:=
cfg
.
Redis
.
Pass
db
:=
cfg
.
Redis
.
DB
maxIdle
:=
cfg
.
Redis
.
Idle
idleTimeout
:=
240
*
time
.
Second
...
...
@@ -44,6 +45,15 @@ func InitRedis() {
}
}
if
db
!=
0
{
if
_
,
err
:=
c
.
Do
(
"SELECT"
,
db
);
err
!=
nil
{
c
.
Close
()
logger
.
Error
(
"redis select db fail, db: "
,
db
)
stats
.
Counter
.
Set
(
"redis.conn.failed"
,
1
)
return
nil
,
err
}
}
return
c
,
err
},
TestOnBorrow
:
PingRedis
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录