From cb281b25134ef7d0a04a1d4e6a6c5cbd0b3df2a7 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Mon, 13 Feb 2023 14:28:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/configs/system.go | 2 +- backend/init/viper/viper.go | 5 +++++ backend/utils/git/git.go | 7 ++++++- cmd/server/conf/app.yaml | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/configs/system.go b/backend/configs/system.go index 2570b9da1..df968ceb1 100644 --- a/backend/configs/system.go +++ b/backend/configs/system.go @@ -8,8 +8,8 @@ type System struct { DataDir string `mapstructure:"data_dir"` Cache string `mapstructure:"cache"` Backup string `mapstructure:"backup"` - AppOss string `mapstructure:"app_oss"` AppRepoOwner string `mapstructure:"app_repo_owner"` AppRepoName string `mapstructure:"app_repo_name"` EncryptKey string `mapstructure:"encrypt_key"` + BaseDir string `mapstructure:"base_dir"` } diff --git a/backend/init/viper/viper.go b/backend/init/viper/viper.go index fe8ebcc8d..0fa56dda3 100644 --- a/backend/init/viper/viper.go +++ b/backend/init/viper/viper.go @@ -18,6 +18,7 @@ import ( func Init() { baseDir := "/opt" + mode := "local" fileOp := files.NewFileOp() v := viper.NewWithOptions() v.SetConfigType("yaml") @@ -28,6 +29,7 @@ func Init() { panic(fmt.Errorf("Fatal error config file: %s \n", err)) } } else { + mode = "release" stdout, err := cmd.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2") if err != nil { panic(err) @@ -50,6 +52,9 @@ func Init() { if err := v.Unmarshal(&serverConfig); err != nil { panic(err) } + if mode == "local" && serverConfig.System.BaseDir != "" { + baseDir = serverConfig.System.BaseDir + } global.CONF = serverConfig global.CONF.BaseDir = baseDir global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel" diff --git a/backend/utils/git/git.go b/backend/utils/git/git.go index 32ff46a4a..5b982484e 100644 --- a/backend/utils/git/git.go +++ b/backend/utils/git/git.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "gitee.com/openeuler/go-gitee/gitee" + "github.com/1Panel-dev/1Panel/backend/global" "github.com/google/go-github/github" "net/http" "time" @@ -28,10 +29,14 @@ func CheckAndGetInfo(owner, repoName string) (*RepoInfo, error) { res, err := getLatestRepoInfo(repoType, owner, repoName) if err == nil { return res, nil + } else { + global.LOG.Errorf("get %s last release version failed %s", repoType, err.Error()) } + } else { + global.LOG.Errorf("get %s remote repo [%s] failed", repoType, url) } } - return nil, errors.New("remote repo get failed") + return nil, errors.New("all remote repo get failed") } func checkValid(addr string) bool { diff --git a/cmd/server/conf/app.yaml b/cmd/server/conf/app.yaml index 5a10f3a9a..b821a0fca 100644 --- a/cmd/server/conf/app.yaml +++ b/cmd/server/conf/app.yaml @@ -1,8 +1,8 @@ system: db_file: 1Panel.db - app_oss: "https://1panel.oss-cn-hangzhou.aliyuncs.com" - app_repo_owner: "1Panel-dev" - app_repo_name: 'appstore' + app_repo_owner: 1Panel-dev + app_repo_name: appstore + base_dir: /opt log: level: debug