Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
0ea4290c
提交
0ea4290c
authored
9月 16, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
d284cba5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
54 行删除
+26
-54
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+2
-1
evdaemon.cpp
opencv-motion-detect/evdaemon.cpp
+24
-53
没有找到文件。
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
0ea4290c
...
@@ -400,7 +400,8 @@ private:
...
@@ -400,7 +400,8 @@ private:
ret
[
"code"
]
=
1
;
ret
[
"code"
]
=
1
;
string
msg
=
"no such sn: "
+
sn
;
string
msg
=
"no such sn: "
+
sn
;
ret
[
"msg"
]
=
msg
;
ret
[
"msg"
]
=
msg
;
spdlog
::
warn
(
"evcloudsvc no config for sn: {}"
,
sn
);
spdlog
::
warn
(
"evcloudsvc no config for sn: {}"
,
sn
);
// TODO: append to retry queue
}
}
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
string
msg
=
"evcloudsvc exception in file"
+
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
" for: "
+
e
.
what
();
string
msg
=
"evcloudsvc exception in file"
+
string
(
__FILE__
)
+
":"
+
to_string
(
__LINE__
)
+
" for: "
+
e
.
what
();
...
...
opencv-motion-detect/evdaemon.cpp
浏览文件 @
0ea4290c
...
@@ -67,7 +67,7 @@ class EvDaemon{
...
@@ -67,7 +67,7 @@ class EvDaemon{
/// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc.
/// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc.
json
mapSubSystems
;
json
mapSubSystems
;
int
reloadCfg
(
string
subModGid
)
{
int
reloadCfg
(
string
subModGid
=
""
)
{
int
bootType
=
0
;
int
bootType
=
0
;
if
(
subModGid
==
"ALL"
)
{
if
(
subModGid
==
"ALL"
)
{
bootType
=
1
;
bootType
=
1
;
...
@@ -77,6 +77,8 @@ class EvDaemon{
...
@@ -77,6 +77,8 @@ class EvDaemon{
bootType
=
3
;
bootType
=
3
;
}
}
spdlog
::
info
(
"evadmon {} reloading config: {}"
,
devSn
,
this
->
config
.
dump
());
int
ret
=
LVDB
::
getSn
(
this
->
info
);
int
ret
=
LVDB
::
getSn
(
this
->
info
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
spdlog
::
error
(
"evdaemon {} failed to get info"
,
this
->
devSn
);
spdlog
::
error
(
"evdaemon {} failed to get info"
,
this
->
devSn
);
...
@@ -116,7 +118,6 @@ class EvDaemon{
...
@@ -116,7 +118,6 @@ class EvDaemon{
}
}
// startup other submodules
// startup other submodules
spdlog
::
info
(
"dump: {}"
,
v
.
dump
());
json
&
ipcs
=
v
[
"ipcs"
];
json
&
ipcs
=
v
[
"ipcs"
];
for
(
auto
&
ipc
:
ipcs
)
{
for
(
auto
&
ipc
:
ipcs
)
{
json
&
modules
=
ipc
[
"modules"
];
json
&
modules
=
ipc
[
"modules"
];
...
@@ -135,7 +136,6 @@ class EvDaemon{
...
@@ -135,7 +136,6 @@ class EvDaemon{
}
}
this
->
peerData
[
"config"
][
peerId
]
=
v
;
this
->
peerData
[
"config"
][
peerId
]
=
v
;
if
(
this
->
peerData
[
"status"
].
count
(
peerId
)
==
0
||
this
->
peerData
[
"status"
][
peerId
]
==
0
)
{
if
(
this
->
peerData
[
"status"
].
count
(
peerId
)
==
0
||
this
->
peerData
[
"status"
][
peerId
]
==
0
)
{
this
->
peerData
[
"status"
][
peerId
]
=
0
;
this
->
peerData
[
"status"
][
peerId
]
=
0
;
if
(
bootType
==
1
||
(
bootType
==
3
&&
subModGid
==
peerId
)){
if
(
bootType
==
1
||
(
bootType
==
3
&&
subModGid
==
peerId
)){
...
@@ -179,7 +179,6 @@ class EvDaemon{
...
@@ -179,7 +179,6 @@ class EvDaemon{
if
(
this
->
peerData
[
"pids"
].
count
(
k
)
!=
0
)
{
if
(
this
->
peerData
[
"pids"
].
count
(
k
)
!=
0
)
{
this
->
peerData
[
"pids"
].
erase
(
k
);
this
->
peerData
[
"pids"
].
erase
(
k
);
}
}
}
}
}
}
...
@@ -187,14 +186,18 @@ class EvDaemon{
...
@@ -187,14 +186,18 @@ class EvDaemon{
// check status and startup
// check status and startup
int
ret
=
0
;
int
ret
=
0
;
vector
<
string
>
tmp
;
vector
<
string
>
tmp
;
string
info
;
int
cnt
=
0
;
for
(
auto
&
[
k
,
v
]
:
this
->
peerData
[
"config"
].
items
())
{
for
(
auto
&
[
k
,
v
]
:
this
->
peerData
[
"config"
].
items
())
{
spdlog
::
info
(
"evdaemon {} submodule {}, config {}"
,
devSn
,
k
,
v
.
dump
());
if
(
this
->
peerData
[
"status"
].
count
(
k
)
==
0
||
this
->
peerData
[
"status"
][
k
]
==
0
)
{
if
(
this
->
peerData
[
"status"
].
count
(
k
)
==
0
||
this
->
peerData
[
"status"
][
k
]
==
0
)
{
tmp
.
push_back
(
k
);
tmp
.
push_back
(
k
);
info
+=
(
cnt
==
0
?
""
:
string
(
", "
))
+
k
;
}
}
cnt
++
;
}
}
spdlog
::
info
(
"evdaemon {} will start following subsystems: {}"
,
devSn
,
info
);
//
//
for
(
string
&
e
:
tmp
)
{
for
(
string
&
e
:
tmp
)
{
pid_t
pid
=
0
;
pid_t
pid
=
0
;
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
e
,
portRouter
,
pid
);
ret
=
zmqhelper
::
forkSubsystem
(
devSn
,
e
,
portRouter
,
pid
);
...
@@ -210,39 +213,6 @@ class EvDaemon{
...
@@ -210,39 +213,6 @@ class EvDaemon{
return
ret
;
return
ret
;
}
}
void
setupSubsystems
()
{
thMon
=
thread
([
this
](){
int
ret
=
0
;
while
(
true
)
{
if
(
this
->
bReload
)
{
//cleanupSubSystems();
ret
=
reloadCfg
(
""
);
if
(
ret
!=
0
)
{
//TODO
spdlog
::
error
(
"evdaemon {} failed to parse new configuration, check prevous log for details"
,
devSn
);
}
else
{
bReload
=
false
;
}
if
(
this
->
bColdStart
)
{
// TODO:
this
->
bColdStart
=
false
;
// for peers to connect
this_thread
::
sleep_for
(
chrono
::
seconds
(
5
));
}
if
(
this
->
bBootstrap
)
{
startSubSystems
();
}
}
this_thread
::
sleep_for
(
chrono
::
seconds
(
5
));
}
});
thMon
.
detach
();
}
int
handleEdgeMsg
(
vector
<
vector
<
uint8_t
>
>
&
body
)
int
handleEdgeMsg
(
vector
<
vector
<
uint8_t
>
>
&
body
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -416,22 +386,24 @@ class EvDaemon{
...
@@ -416,22 +386,24 @@ class EvDaemon{
spdlog
::
error
(
"evdaemon {} received invalid empty config"
,
devSn
);
spdlog
::
error
(
"evdaemon {} received invalid empty config"
,
devSn
);
}
else
{
}
else
{
this
->
deltaCfg
=
json
::
diff
(
this
->
config
,
data
);
this
->
deltaCfg
=
json
::
diff
(
this
->
config
,
data
);
if
(
this
->
deltaCfg
.
size
()
!=
0
)
{
spdlog
::
info
(
"evdaemon {} received cloud config diff: {}
\n
new: {}"
,
devSn
,
this
->
deltaCfg
.
dump
(
4
),
data
.
dump
());
if
(
this
->
deltaCfg
.
size
()
!=
0
||
this
->
bColdStart
)
{
this
->
config
=
data
;
this
->
config
=
data
;
this
->
bReload
=
true
;
ret
=
reloadCfg
();
spdlog
::
info
(
"evdaemon {} received cloud config diff:
\n
{}
\n
new
\n
{}"
,
devSn
,
this
->
deltaCfg
.
dump
(
4
),
data
.
dump
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evdameon {} failed to parse new config: {}"
,
devSn
,
data
.
dump
());
return
ret
;
}
ret
=
LVDB
::
setLocalConfig
(
data
,
""
,
EV_FILE_LVDB_DAEMON
);
ret
=
LVDB
::
setLocalConfig
(
data
,
""
,
EV_FILE_LVDB_DAEMON
);
if
(
ret
<
0
)
{
if
(
ret
!=
0
)
{
spdlog
::
error
(
"evdameon {} failed to save new config to local db: {}"
,
devSn
,
data
.
dump
());
spdlog
::
error
(
"evdameon {} failed to save new config to local db: {}"
,
devSn
,
data
.
dump
());
return
ret
;
}
}
// TODO: detailed diff on submodules
this
->
bColdStart
=
false
;
}
else
{
}
else
{
if
(
this
->
bColdStart
)
{
startSubSystems
();
}
else
{
spdlog
::
info
(
"evdaemon {} received same configuration and ignored: {}"
,
devSn
,
data
.
dump
());
}
}
}
startSubSystems
();
}
}
}
}
}
else
{
}
else
{
...
@@ -449,9 +421,7 @@ class EvDaemon{
...
@@ -449,9 +421,7 @@ class EvDaemon{
protected
:
protected
:
public
:
public
:
void
run
(){
void
run
(){
//setupSubsystems();
setupSubsystems
();
// get config
// get config
svr
.
Get
(
"/info"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
svr
.
Get
(
"/info"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
LVDB
::
getSn
(
this
->
info
);
LVDB
::
getSn
(
this
->
info
);
...
@@ -554,9 +524,10 @@ class EvDaemon{
...
@@ -554,9 +524,10 @@ class EvDaemon{
json
cfg
;
json
cfg
;
ret
=
LVDB
::
getLocalConfig
(
cfg
,
""
,
EV_FILE_LVDB_DAEMON
);
ret
=
LVDB
::
getLocalConfig
(
cfg
,
""
,
EV_FILE_LVDB_DAEMON
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
spdlog
::
info
(
"evda
meon {} no local config"
,
devSn
,
cfg
.
dump
()
);
spdlog
::
info
(
"evda
emon {} no local config"
,
devSn
);
}
else
{
}
else
{
this
->
config
=
cfg
;
this
->
config
=
cfg
;
spdlog
::
info
(
"evdaemon {} local config: {}"
,
devSn
,
cfg
.
dump
());
}
}
// zmq router port
// zmq router port
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论