Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
obagent
提交
cb9075aa
O
obagent
项目概览
oceanbase
/
obagent
1 年多 前同步成功
通知
3
Star
15
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obagent
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cb9075aa
编写于
1月 24, 2022
作者:
C
chris-sun-star
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix startup
上级
4f256847
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
19 addition
and
8 deletion
+19
-8
engine/monagent_server.go
engine/monagent_server.go
+19
-8
未找到文件。
engine/monagent_server.go
浏览文件 @
cb9075aa
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/oceanbase/obagent/api/route"
"github.com/oceanbase/obagent/api/route"
"github.com/oceanbase/obagent/api/web"
"github.com/oceanbase/obagent/api/web"
"github.com/oceanbase/obagent/config"
"github.com/oceanbase/obagent/config"
"github.com/oceanbase/obagent/utils"
)
)
var
monitorAgentServer
*
MonitorAgentServer
var
monitorAgentServer
*
MonitorAgentServer
...
@@ -38,8 +39,8 @@ type MonitorAgentServer struct {
...
@@ -38,8 +39,8 @@ type MonitorAgentServer struct {
Server
*
web
.
HttpServer
Server
*
web
.
HttpServer
// server of pprof
// server of pprof
AdminServer
*
web
.
HttpServer
AdminServer
*
web
.
HttpServer
//
two servers concurrent waitGrou
p
//
server status ma
p
wg
*
sync
.
WaitGrou
p
serverStatusMap
sync
.
Ma
p
}
}
// NewMonitorAgentServer init monagent server: init configs and logger, register routers
// NewMonitorAgentServer init monagent server: init configs and logger, register routers
...
@@ -60,7 +61,6 @@ func NewMonitorAgentServer(conf *config.MonitorAgentConfig) *MonitorAgentServer
...
@@ -60,7 +61,6 @@ func NewMonitorAgentServer(conf *config.MonitorAgentConfig) *MonitorAgentServer
Server
:
&
http
.
Server
{},
Server
:
&
http
.
Server
{},
Address
:
conf
.
Server
.
AdminAddress
,
Address
:
conf
.
Server
.
AdminAddress
,
},
},
wg
:
&
sync
.
WaitGroup
{},
}
}
monitorAgentServer
=
monagentServer
monitorAgentServer
=
monagentServer
return
monitorAgentServer
return
monitorAgentServer
...
@@ -68,21 +68,32 @@ func NewMonitorAgentServer(conf *config.MonitorAgentConfig) *MonitorAgentServer
...
@@ -68,21 +68,32 @@ func NewMonitorAgentServer(conf *config.MonitorAgentConfig) *MonitorAgentServer
// Run start mongagent servers: admin server, monitor server
// Run start mongagent servers: admin server, monitor server
func
(
server
*
MonitorAgentServer
)
Run
()
error
{
func
(
server
*
MonitorAgentServer
)
Run
()
error
{
server
.
wg
.
Add
(
1
)
// check port available before start server
go
func
()
{
go
func
()
{
defer
server
.
wg
.
Done
(
)
server
.
serverStatusMap
.
Store
(
"adminServer"
,
false
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
server
.
AdminServer
.
Cancel
=
cancel
server
.
AdminServer
.
Cancel
=
cancel
server
.
AdminServer
.
Run
(
ctx
)
server
.
AdminServer
.
Run
(
ctx
)
}()
}()
server
.
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
defer
server
.
wg
.
Done
(
)
server
.
serverStatusMap
.
Store
(
"server"
,
false
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
server
.
Server
.
Cancel
=
cancel
server
.
Server
.
Cancel
=
cancel
server
.
Server
.
Run
(
ctx
)
server
.
Server
.
Run
(
ctx
)
}()
}()
server
.
wg
.
Wait
()
for
{
adminServerStatus
,
_
:=
server
.
serverStatusMap
.
LoadOrStore
(
"adminServer"
,
true
)
serverStatus
,
_
:=
server
.
serverStatusMap
.
LoadOrStore
(
"server"
,
true
)
adminServerOk
,
convertAdminServerOk
:=
utils
.
ConvertToBool
(
adminServerStatus
)
serverOk
,
convertServerOk
:=
utils
.
ConvertToBool
(
serverStatus
)
if
!
(
convertAdminServerOk
&&
convertServerOk
)
{
return
errors
.
New
(
"start monagent server failed, adminSer"
)
}
if
!
(
adminServerOk
&&
serverOk
)
{
return
errors
.
New
(
"start monagent server failed, adminSer"
)
}
}
return
nil
return
nil
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录