|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"context"
|
|
"context"
|
|
|
|
|
+ "encoding/json"
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"os"
|
|
"os"
|
|
@@ -17,13 +18,13 @@ import (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type serviceUpgradeConfig struct {
|
|
type serviceUpgradeConfig struct {
|
|
|
- Name string // 去掉"yfkj-"前缀和".service"
|
|
|
|
|
- // 后缀的服务名, 也是升级包中可执行程序的名称
|
|
|
|
|
- Enable bool /// 是否启用自动升级//
|
|
|
|
|
- CheckVerURL string /// 版本检查的 URL //
|
|
|
|
|
- ClonePkgURL string /// 升级包克隆 URL //
|
|
|
|
|
- InstallPath string /// 服务安装的路径 //
|
|
|
|
|
- ReplaceDirs []string /// 需要安装的目录 //
|
|
|
|
|
|
|
+ Name string `json:"name"` // 去掉"yfkj-"前缀和".service"后缀的
|
|
|
|
|
+ // 服务名, 也是升级包中可执行程序的名称
|
|
|
|
|
+ Enable bool `json:"enable"` /// 是否启用自动升级/
|
|
|
|
|
+ CheckVerURL string `json:"checkVerURL"` /// 版本检查的 URL /
|
|
|
|
|
+ ClonePkgURL string `json:"clonePkgURL"` /// 升级包克隆 URL /
|
|
|
|
|
+ InstallPath string `json:"installPath"` /// 服务安装的路径 /
|
|
|
|
|
+ ReplaceDirs []string `json:"replaceDirs"` /// 需要安装的目录 /
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var upgradeServices = []serviceUpgradeConfig{
|
|
var upgradeServices = []serviceUpgradeConfig{
|
|
@@ -86,6 +87,23 @@ var upgradeServices = []serviceUpgradeConfig{
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (p *program) loadUpgradeConfig() {
|
|
|
|
|
+ configFile := filepath.Join(baseapp.CFG_DIR, "upgrade.json")
|
|
|
|
|
+
|
|
|
|
|
+ data, err := os.ReadFile(configFile)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var services []serviceUpgradeConfig
|
|
|
|
|
+ if err := json.Unmarshal(data, &services); err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ upgradeServices = services
|
|
|
|
|
+ baseapp.Logger.Infof("[%s] 使用外部升级配置", p.name)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func isNetworkOK() bool {
|
|
func isNetworkOK() bool {
|
|
|
_, _, tcpOK, httpOK, _ := netmgrd.CheckNetwork()
|
|
_, _, tcpOK, httpOK, _ := netmgrd.CheckNetwork()
|
|
|
return tcpOK || httpOK
|
|
return tcpOK || httpOK
|