zhou.xiaoning %!s(int64=3) %!d(string=hai) anos
pai
achega
b0e7797c2f
Modificáronse 3 ficheiros con 12 adicións e 7 borrados
  1. 10 1
      api/console/update.go
  2. 0 2
      go.sum
  3. 2 4
      service/mq/mq.go

+ 10 - 1
api/console/update.go

@@ -3,6 +3,7 @@ package console
 import (
 	_ "embed"
 	"fmt"
+	"mtp20access/global"
 	"net/http"
 	"os"
 	"os/exec"
@@ -21,11 +22,12 @@ var IsUpdateing = false
 
 // MakeUpdateScript 生成脚本
 func MakeUpdateScript(c *gin.Context) {
+	global.M2A_LOG.Info("111111111")
 	if IsUpdateing {
 		c.String(http.StatusOK, "正在升级中...")
 		return
 	}
-
+	global.M2A_LOG.Info("22222222")
 	if runtime.GOOS == "windows" {
 		c.String(http.StatusOK, "windows不支持, 仅支持linux下执行")
 		return
@@ -36,8 +38,11 @@ func MakeUpdateScript(c *gin.Context) {
 		IsUpdateing = false
 	}()
 
+	global.M2A_LOG.Info("33333333")
+
 	filename := c.DefaultQuery("filename", "")
 	if createsh() {
+		global.M2A_LOG.Info("7777777777")
 		c.String(http.StatusOK, "正在执行升级, 升级会保留原有的config.yaml,且重启服务。注意:请勿刷新本页面。")
 		rx := regexp.MustCompile(`mtp20_access_*\.zip`) // mtp20_access_20221009092417.zip
 		names := rx.FindStringSubmatch(filename)
@@ -51,18 +56,21 @@ func MakeUpdateScript(c *gin.Context) {
 			_ = exec.Command("sh", "./update.sh").Run()
 		}
 	} else {
+		global.M2A_LOG.Info("88888888888888888")
 		c.String(http.StatusBadRequest, "创建脚本失败, 可能是权限不足")
 	}
 }
 
 // 生成update.sh文件
 func createsh() bool {
+	global.M2A_LOG.Info("4444444444")
 	dir := ""
 	if str, err := filepath.Abs(filepath.Dir(os.Args[0])); err == nil {
 		dir = strings.Replace(str, "\\", "/", -1)
 	} else {
 		return false
 	}
+	global.M2A_LOG.Info("555555555555")
 	// 创建文件
 	if f, err := os.OpenFile(dir+"/update.sh", os.O_RDWR|os.O_TRUNC|os.O_CREATE, 0666); err == nil {
 		f.Write([]byte(strShell))
@@ -70,5 +78,6 @@ func createsh() bool {
 	} else {
 		return false
 	}
+	global.M2A_LOG.Info("66666666666")
 	return true
 }

+ 0 - 2
go.sum

@@ -259,8 +259,6 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51
 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
 github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
 github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
-github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
-github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
 github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=

+ 2 - 4
service/mq/mq.go

@@ -45,12 +45,10 @@ func SendMQ(c *gin.Context, req *request.MQBodyReq) (err error) {
 	asyncTask := global.AsyncTask{
 		FuncodeRsp:   req.FunCodeRsp,
 		SerialNumber: serialNumber,
-		//C:            c.Copy(),
-		Own:         client,
-		IsEncrypted: *req.IsEncrypted,
+		Own:          client,
+		IsEncrypted:  *req.IsEncrypted,
 	}
 	client.SetAsyncTask(&asyncTask, key)
-	// go asyncTask.Run()
 
 	// 获取对应主题
 	topic, exists := global.M2A_FuncodeTopic[int(req.FunCodeReq)]