Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ba84e617
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba84e617
编写于
8月 06, 2021
作者:
Y
Ybjjwwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix transfer
上级
61bc89d0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
68 deletion
+61
-68
core/cube/cube-transfer/src/transfer/transfer.go
core/cube/cube-transfer/src/transfer/transfer.go
+37
-49
core/cube/cube-transfer/src/transfer/trigger.go
core/cube/cube-transfer/src/transfer/trigger.go
+21
-17
core/cube/cube-transfer/src/transfer/util.go
core/cube/cube-transfer/src/transfer/util.go
+3
-2
未找到文件。
core/cube/cube-transfer/src/transfer/transfer.go
浏览文件 @
ba84e617
...
...
@@ -17,68 +17,56 @@ package transfer
import
(
"fmt"
"github.com/Badangel/logex"
"os"
"time"
"transfer/dict"
)
func
Start
()
{
go
BackupTransfer
()
logex
.
Notice
(
">>> starting server..."
)
addr
:=
":"
+
Port
err
:=
startHttp
(
addr
)
if
err
!=
nil
{
logex
.
Fatalf
(
"start http(addr=%v) failed: %v"
,
addr
,
err
)
os
.
Exit
(
255
)
}
logex
.
Notice
(
">>> start server succ"
)
BackupTransfer
()
}
func
BackupTransfer
()
{
for
{
//trigger
version
,
err
:=
TriggerStart
(
Dict
.
DonefileAddress
)
if
err
!=
nil
{
logex
.
Fatalf
(
"[trigger err]trigger err:%v "
,
err
)
fmt
.
Printf
(
"[error]trigger err:%v
\n
"
,
err
)
break
}
logex
.
Noticef
(
"[trigger] get version:%v
\n
"
,
version
)
if
version
.
Id
==
0
{
logex
.
Noticef
(
"[sleep]no new version, sleep 5 min"
)
fmt
.
Printf
(
"[sleep]no new version, wait 5 min
\n
"
)
time
.
Sleep
(
5
*
time
.
Minute
)
continue
}
//trigger
version
,
err
:=
TriggerStart
(
Dict
.
DonefileAddress
)
if
err
!=
nil
{
logex
.
Fatalf
(
"[trigger err]trigger err:%v "
,
err
)
fmt
.
Printf
(
"[error]trigger err:%v
\n
"
,
err
)
fmt
.
Print
(
"transfer over!"
)
logex
.
Noticef
(
"[transfer]status machine exit!"
)
return
}
logex
.
Noticef
(
"[trigger] get version:%v
\n
"
,
version
)
Dict
.
WaitVersionInfo
=
version
logex
.
Noticef
(
"[trigger finish] WaitVersionInfo version:%v
\n
"
,
Dict
.
WaitVersionInfo
)
WriteWaitVersionInfoToFile
()
logex
.
Noticef
(
"[trigger finish] WaitVersionInfo version:%v
\n
"
,
Dict
.
WaitVersionInfo
)
WriteWaitVersionInfoToFile
()
//builder
Dict
.
WaitVersionInfo
.
Status
=
dict
.
Dict_Status_Building
Dict
.
WaitVersionInfo
.
MetaInfos
=
make
(
map
[
int
]
string
)
WriteWaitVersionInfoToFile
()
if
err
=
BuilderStart
(
Dict
.
WaitVersionInfo
);
err
!=
nil
{
logex
.
Fatalf
(
"builder err:%v
\n
"
,
err
)
}
//builder
Dict
.
WaitVersionInfo
.
Status
=
dict
.
Dict_Status_Building
Dict
.
WaitVersionInfo
.
MetaInfos
=
make
(
map
[
int
]
string
)
WriteWaitVersionInfoToFile
()
if
err
=
BuilderStart
(
Dict
.
WaitVersionInfo
);
err
!=
nil
{
logex
.
Fatalf
(
"builder err:%v
\n
"
,
err
)
}
if
Dict
.
WaitVersionInfo
.
Mode
==
dict
.
BASE
{
var
newCurrentVersion
[]
dict
.
DictVersionInfo
Dict
.
CurrentVersionInfo
=
newCurrentVersion
WriteCurrentVersionInfoToFile
()
}
logex
.
Noticef
(
"[builder finish] WaitVersionInfo version:%v
\n
"
,
Dict
.
WaitVersionInfo
)
if
Dict
.
WaitVersionInfo
.
Mode
==
dict
.
BASE
{
var
newCurrentVersion
[]
dict
.
DictVersionInfo
Dict
.
CurrentVersionInfo
=
newCurrentVersion
WriteCurrentVersionInfoToFile
()
}
if
Dict
.
WaitVersionInfo
.
Mode
==
dict
.
DELTA
{
var
newCurrentVersion
[]
dict
.
DictVersionInfo
Dict
.
CurrentVersionInfo
=
newCurrentVersion
WriteCurrentVersionInfoToFile
()
}
logex
.
Noticef
(
"[builder finish] WaitVersionInfo version:%v
\n
"
,
Dict
.
WaitVersionInfo
)
//deployer
Dict
.
WaitVersionInfo
.
Status
=
dict
.
Dict_Status_Deploying
WriteWaitVersionInfoToFile
()
if
err
=
DeployStart
(
Dict
.
WaitVersionInfo
);
err
!=
nil
{
logex
.
Fatalf
(
"deploy err:%v
\n
"
,
err
)
}
logex
.
Noticef
(
"[deploy finish]current version: %v
\n
"
,
Dict
.
CurrentVersionInfo
)
//deployer
Dict
.
WaitVersionInfo
.
Status
=
dict
.
Dict_Status_Deploying
WriteWaitVersionInfoToFile
()
if
err
=
DeployStart
(
Dict
.
WaitVersionInfo
);
err
!=
nil
{
logex
.
Fatalf
(
"deploy err:%v
\n
"
,
err
)
}
logex
.
Noticef
(
"[deploy finish]current version: %v
\n
"
,
Dict
.
CurrentVersionInfo
)
fmt
.
Print
(
"transfer over!"
)
logex
.
Noticef
(
"[transfer]status machine exit!"
)
}
core/cube/cube-transfer/src/transfer/trigger.go
浏览文件 @
ba84e617
...
...
@@ -38,18 +38,19 @@ func GetDoneFileInfo(addr string) (version dict.DictVersionInfo, err error) {
Wget
(
addr
,
donefileAddr
)
addr
=
donefileAddr
}
baseDonefile
:=
addr
+
"/base.txt"
fmt
.
Printf
(
"[trigrer]donefile path:%v
\n
"
,
baseDonefile
)
logex
.
Noticef
(
"[trigrer]base donefile path:%v"
,
baseDonefile
)
contents
,
err
:=
ioutil
.
ReadFile
(
baseDonefile
)
VersionLen
:=
len
(
Dict
.
CurrentVersionInfo
)
version
.
DictName
=
Dict
.
DictName
if
err
!=
nil
{
fmt
.
Printf
(
"[trigrer]read files err:%v
\n
"
,
err
)
logex
.
Fatalf
(
"[trigrer]read files err:%v "
,
err
)
fmt
.
Printf
(
"get into mode check here
\n
"
)
if
Dict
.
DictMode
==
dict
.
BASE_ONLY
{
baseDonefile
:=
addr
+
"/base.txt"
fmt
.
Printf
(
"[trigrer]donefile path:%v
\n
"
,
baseDonefile
)
logex
.
Noticef
(
"[trigrer]base donefile path:%v"
,
baseDonefile
)
contents
,
err_0
:=
ioutil
.
ReadFile
(
baseDonefile
)
if
err_0
!=
nil
{
fmt
.
Printf
(
"[trigrer]read files err:%v
\n
"
,
err_0
)
logex
.
Fatalf
(
"[trigrer]read files err:%v "
,
err_0
)
return
}
else
{
}
else
{
contentss
:=
string
(
contents
)
lines
:=
strings
.
Split
(
contentss
,
"
\n
"
)
index
:=
len
(
lines
)
-
1
...
...
@@ -80,19 +81,21 @@ func GetDoneFileInfo(addr string) (version dict.DictVersionInfo, err error) {
version
.
Mode
=
dict
.
BASE
return
}
}
if
Dict
.
DictMode
==
dict
.
BASR_DELTA
&&
VersionLen
>
0
{
}
}
if
Dict
.
DictMode
==
dict
.
BASR_DELTA
{
patchDonefile
:=
addr
+
"/patch.txt"
fmt
.
Printf
(
"[trigrer]patchDonefile path:%v
\n
"
,
patchDonefile
)
logex
.
Noticef
(
"[trigrer]patch donefile path:%v"
,
patchDonefile
)
contents
,
err
=
ioutil
.
ReadFile
(
patchDonefile
)
if
err
!=
nil
{
fmt
.
Printf
(
"read files err:%v
\n
"
,
err
)
contents
,
err_0
:=
ioutil
.
ReadFile
(
patchDonefile
)
if
err_0
!=
nil
{
fmt
.
Printf
(
"[trigrer]read files err:%v
\n
"
,
err_0
)
logex
.
Fatalf
(
"[trigrer]read files err:%v "
,
err_0
)
return
}
else
{
contentss
:=
string
(
contents
)
lines
:=
strings
.
Split
(
contentss
,
"
\n
"
)
fmt
.
Printf
(
"[trigger]get patch lines here
\n
"
)
for
index
:=
0
;
index
<
len
(
lines
)
-
1
;
index
++
{
if
len
(
lines
[
index
])
<
3
{
logex
.
Noticef
(
"[trigrer]get patch donfile info error"
)
...
...
@@ -106,14 +109,15 @@ func GetDoneFileInfo(addr string) (version dict.DictVersionInfo, err error) {
logex
.
Noticef
(
"[trigrer]donfile info:%v"
,
donefileInfo
)
newId
,
_
:=
strconv
.
Atoi
(
donefileInfo
.
Id
)
newKey
,
_
:=
strconv
.
Atoi
(
donefileInfo
.
Key
)
if
newId
>
Dict
.
CurrentVersionInfo
[
VersionLen
-
1
]
.
Id
&&
newKey
==
Dict
.
CurrentVersionInfo
[
VersionLen
-
1
]
.
Key
{
fmt
.
Printf
(
"[trigger]read patch id: %d, key: %d
\n
"
,
newId
,
newKey
)
if
VersionLen
==
0
||
newId
>
Dict
.
CurrentVersionInfo
[
VersionLen
-
1
]
.
Id
{
version
.
Id
=
newId
version
.
Key
,
_
=
strconv
.
Atoi
(
donefileInfo
.
Key
)
version
.
Input
=
donefileInfo
.
Input
deployVersion
:=
int
(
time
.
Now
()
.
Unix
())
version
.
CreateTime
=
deployVersion
version
.
Version
=
deployVersion
version
.
Depend
=
Dict
.
CurrentVersionInfo
[
VersionLen
-
1
]
.
Depend
version
.
Depend
=
deployVersion
version
.
Mode
=
dict
.
DELTA
return
}
...
...
core/cube/cube-transfer/src/transfer/util.go
浏览文件 @
ba84e617
...
...
@@ -96,7 +96,8 @@ func ExeCommad(files string, params []string) (err error) {
func
Wget
(
ftpPath
string
,
downPath
string
)
{
var
params
[]
string
params
=
append
(
params
,
"-P"
)
params
=
append
(
params
,
"--limit-rate=100m"
)
params
=
append
(
params
,
"-P"
)
params
=
append
(
params
,
downPath
)
params
=
append
(
params
,
"-r"
)
params
=
append
(
params
,
"-N"
)
...
...
@@ -110,4 +111,4 @@ func Wget(ftpPath string, downPath string) {
if
err
!=
nil
{
fmt
.
Printf
(
"wget exe: %v
\n
"
,
err
)
}
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录