Them retry khi download module loi va bat truong hop gui lenh update module nhieu lan tu server
This commit is contained in:
parent
56c9eaec33
commit
63727cd2f2
Binary file not shown.
|
@ -462,12 +462,14 @@ func MqttMessageHandler(MqttBI mqtt.Client, message mqtt.Message) {
|
||||||
} else if list["method"] == "update_model" { // {"method":"update_model","status": 1}
|
} else if list["method"] == "update_model" { // {"method":"update_model","status": 1}
|
||||||
file.Println("Update_model \n")
|
file.Println("Update_model \n")
|
||||||
fmt.Printf("%v--%T", list["id_box_engine"], list["id_box_engine"])
|
fmt.Printf("%v--%T", list["id_box_engine"], list["id_box_engine"])
|
||||||
UpdateModule((int)((list["id_box_engine"]).(float64)))
|
if SttUpdate == false {
|
||||||
topic := strings.Replace(message.Topic(), "request", "response", 1)
|
UpdateModule((int)((list["id_box_engine"]).(float64)))
|
||||||
msg := `{"method":"update_model","status": ` + strconv.Itoa(1) + `}`
|
topic := strings.Replace(message.Topic(), "request", "response", 1)
|
||||||
file.Write_log("Message:"+msg+" \n", box.Path_log_luncher)
|
msg := `{"method":"update_model","status": ` + strconv.Itoa(1) + `}`
|
||||||
CmsResponse(MqttBI, topic, msg)
|
file.Write_log("Message:"+msg+" \n", box.Path_log_luncher)
|
||||||
file.Println("UpdateModule done\n")
|
CmsResponse(MqttBI, topic, msg)
|
||||||
|
file.Println("UpdateModule done\n")
|
||||||
|
}
|
||||||
|
|
||||||
} else if list["method"] == "inactive_box" {
|
} else if list["method"] == "inactive_box" {
|
||||||
file.Println("Inactive Box\n")
|
file.Println("Inactive Box\n")
|
||||||
|
@ -557,11 +559,13 @@ func MqttMessageHandler(MqttBI mqtt.Client, message mqtt.Message) {
|
||||||
|
|
||||||
}
|
}
|
||||||
func UpdateModule(id_engine int) {
|
func UpdateModule(id_engine int) {
|
||||||
|
file.Write_log("-------- START UPDATE MODULE ----------", box.Path_log_luncher)
|
||||||
SttUpdate = true
|
SttUpdate = true
|
||||||
box.Stop_check_engine()
|
box.Stop_check_engine()
|
||||||
box.Stop_Server_Engine()
|
box.Stop_Server_Engine()
|
||||||
box.RequestUpdate_Module(box.Url_module, id_engine)
|
box.RequestUpdate_Module(box.Url_module, id_engine)
|
||||||
SttUpdate = false
|
SttUpdate = false
|
||||||
|
file.Write_log("---------------------------------------", box.Path_log_luncher)
|
||||||
}
|
}
|
||||||
func UpdateEngine() {
|
func UpdateEngine() {
|
||||||
SttUpdate = true
|
SttUpdate = true
|
||||||
|
|
23
box/box.go
23
box/box.go
|
@ -1000,15 +1000,22 @@ func RequestUpdate_Module(url string, id_engine int) {
|
||||||
file.Write_log("API get module :"+url, Path_log_luncher)
|
file.Write_log("API get module :"+url, Path_log_luncher)
|
||||||
file.Write_log("Path:"+path, Path_log_luncher)
|
file.Write_log("Path:"+path, Path_log_luncher)
|
||||||
file.Write_log("Download Started", Path_log_luncher)
|
file.Write_log("Download Started", Path_log_luncher)
|
||||||
err := DownloadFile(path, url)
|
var number_download = 0
|
||||||
if err != nil {
|
for {
|
||||||
// panic(err)
|
number_download = number_download + 1
|
||||||
file.Write_log("Download Error", Path_log_luncher)
|
err := DownloadFile(path, url)
|
||||||
} else {
|
if err != nil {
|
||||||
file.Write_log("Download Finished", Path_log_luncher)
|
// panic(err)
|
||||||
file.Write_log("Save thanh cong modules", Path_log_luncher)
|
file.Write_log("Download Error", Path_log_luncher)
|
||||||
Res_Server(message.Data.Engines[i].Url, message.Data.Box_id, message.Data.Engines[i].Id)
|
} else {
|
||||||
|
file.Write_log("Download Finished", Path_log_luncher)
|
||||||
|
file.Write_log("Save thanh cong modules", Path_log_luncher)
|
||||||
|
Res_Server(message.Data.Engines[i].Url, message.Data.Box_id, message.Data.Engines[i].Id)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
file.Write_log("Number download module: "+strconv.Itoa(number_download), Path_log_luncher)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user