From 761859b5fa66372c8cb728da311c3dab9386ddd8 Mon Sep 17 00:00:00 2001 From: cdle Date: Fri, 7 Jul 2023 17:23:43 +0800 Subject: [PATCH] x --- core/init.go | 15 +++++++++++++-- core/web.go | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/init.go b/core/init.go index a205dc9..b40c1fc 100644 --- a/core/init.go +++ b/core/init.go @@ -53,12 +53,22 @@ func Init() { // utils.ReadYaml(utils.ExecPath+"/conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyplus/main/conf/demo_config.yaml") initToHandleMessage() sillyGirl.Set("compiled_at", compiled_at) - console.Log("编译版本:%s", compiled_at) + console.Log("编译版本: %s", compiled_at) initWeb() initCarry() sillyGirl.Set("started_at", time.Now().Format("2006-01-02 15:04:05")) + var updates = 0 storage.Watch(sillyGirl, "compiled_at", func(old, new, key string) *storage.Final { if old != new { + if updates == 0 { + return &storage.Final{ + Message: "升级中,请耐心等待...", + } + } + updates++ + defer func() { + updates-- + }() var transport *http.Transport instance, err := GetProxyTransport("https://raw.githubusercontent.com", "", nil) if err != nil { @@ -91,14 +101,15 @@ func Init() { var resp *http.Response var req *http.Request - console.Debug("正在从 cdle/binary 获取版本号...") proxy := false qurl := "https://raw.githubusercontent.com/cdle/binary/main/compile_time.go" version, _ := GetVersion() if version != "" { + console.Debug("正在从 github 获取版本号...") latest_version = version } else { + console.Debug("正在从 cdle/binary 获取版本号...") req, _ = http.NewRequest("GET", qurl, strings.NewReader("")) resp, err = client.Do(req) if err != nil { diff --git a/core/web.go b/core/web.go index 4e98a89..0e4e108 100644 --- a/core/web.go +++ b/core/web.go @@ -339,9 +339,9 @@ func initWeb() { srvs = append(srvs, srv) go func() { - logs.Info("Http服务(%d)重新运行", port) + logs.Info("Http服务(%v)重新运行", port) if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { - logs.Error("Http服务(%d)运行失败:%s", port, err.Error()) + logs.Error("Http服务(%v)运行失败:%s", port, err.Error()) ch <- err } }() @@ -369,10 +369,10 @@ func initWeb() { logs.Info("管理员面板:") logs.Info(" > 本机: http://localhost:%d/admin", port) local_ip := getLocalIP() - logs.Info(" > 局域网: http://%s:%d/admin", local_ip, port) + logs.Info(" > 局域网: http://%v:%d/admin", local_ip, port) ip := sillyGirl.GetString("ip") if ip != "" { - logs.Info(" > 广域网: http://%s:%d/admin", ip, port) + logs.Info(" > 广域网: http://%v:%d/admin", ip, port) } sillyGirl.Set("local_ip", local_ip) go func() {