Commit b207557c authored by szh's avatar szh

添加树莓派节点版本更新 节点内部更新数据的状态的获知

parent 4ec0bd2f
......@@ -340,6 +340,22 @@ response
```
### bityuan更新重启后 查看内部区块和数据库是否更新完成 内网接口
URL /pai/nodeupdate
请求方法 post json
|参数|类型|是否必填|说明|
```
response
{
"code": 200,
"msg": "ok",
"status": true //true 表示还在内部更新中
}
```
## 节点部署:
监控程序代码默认放在/home/pi目录下面
钱包节点程序命名为v7-bityuan
......
......@@ -51,4 +51,8 @@ func (p *PaiClient) Close() (*types.Reply,error) {
func (p *PaiClient) Unlock(lock *types.WalletUnLock)(*types.Reply,error){
return paiClient.UnLock(context.Background(),lock)
}
func (p *PaiClient) IsSync() (*types.Reply,error) {
return paiClient.IsSync(context.Background(),&types.ReqNil{})
}
\ No newline at end of file
......@@ -613,4 +613,27 @@ func EscrowPasswd(c *gin.Context){
f.WriteString(passwd.Password)
appG.Response(http.StatusOK,e.SUCCESS,nil)
}
//如果bityuan进程开启 端口没开启 默认认为是在版本内部升级过程中 确定是否还在版本更新中 status false 表示已同步完成 true 表示还在版本同步中
func UpdateNodeStatus(c *gin.Context){
appG:=app.Gin{C:c}
var update bool
var buf bytes.Buffer
cmd := exec.Command("netstat", "-tunlp")
cmd.Stdout = &buf
err := cmd.Run()
if err != nil {
appG.Response(http.StatusOK,e.NODE_ERROR,nil)
return
}
//程序运行 + 端口没开启
if strings.Contains(buf.String(),"v7-bityuan") && !strings.Contains(buf.String(),":8801") && strings.Contains(buf.String(),":6060") {
update = true
} else if !strings.Contains(buf.String(),"v7-bityuan") {
appG.Response(http.StatusOK,e.NODE_ERROR,nil)
return
}
appG.Response(http.StatusOK,e.SUCCESS,gin.H{
"status":update,
})
}
\ No newline at end of file
......@@ -18,7 +18,10 @@ func InitRouter() *gin.Engine {
apiv1.POST("/devdetail",v1.GetDevdetail)
//获取树莓派基本信息
apiv1.POST("/resetwallet",v1.ResetWallet)
//更新bityuan节点 下载替换 重启
apiv1.POST("/updatenode",v1.UpdateNodeNew)
//检查节点是否还在更新同步 节点6.4.0大版本更新可能需要十几个小时 故加此接口
apiv1.POST("/nodeupdate",v1.UpdateNodeStatus)
apiv1.POST("/devstatus",v1.GetDevstatus)
apiv1.POST("/updatedetail",v1.UpdateDetail)
apiv1.POST("/version",v1.Version)
......@@ -40,7 +43,7 @@ func InitRouter() *gin.Engine {
//反馈处理进度
apiv1.POST("/iscomplete",v1.FeedBackStatus)
apiv1.POST("/escrowpassword",v1.EscrowPasswd)
//更新完成用户手动重启设备
//pai更新完成用户手动重启设备
apiv1.POST("/isreboot",v1.IsReBoot)
return r
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment