Forráskód Böngészése

增加版本信息

zou.yingbin 4 éve
szülő
commit
69e3154150
2 módosított fájl, 19 hozzáadás és 2 törlés
  1. 11 2
      controllers/other/logfilelist.go
  2. 8 0
      main.go

+ 11 - 2
controllers/other/logfilelist.go

@@ -16,6 +16,11 @@ import (
 	"strings"
 )
 
+var (
+	VERSION string
+	GITHASH string
+)
+
 // LogList 列出日志文件
 func LogList(c *gin.Context) {
 	host := c.Request.Host
@@ -24,10 +29,13 @@ func LogList(c *gin.Context) {
 	}
 
 	const templateText = `
-<h1>日志文件列表</h1>
+<h1>go查询服务信息</h1>
+version : {{.version}}<br>
+git hash: {{.githash}}<br>
 oracle : {{.db}} <br>
 mysql  : {{.mysql}} <br>
 redis  : {{.redis}} <br>
+<h1>日志文件列表</h1>
 <p>------------------------</p>
 {{.data}}
 <p>------------------------</p>
@@ -61,7 +69,8 @@ redis  : {{.redis}} <br>
 		str := strings.Join(sFile, "\n<br>")
 		if tmpl, err := template.New("index").Parse(templateText); err == nil {
 			_ = tmpl.Execute(c.Writer, gin.H{"data": template.HTML(str), "db": template.HTML(db),
-				"mysql": template.HTML(mysql), "redis": template.HTML(redis)})
+				"mysql": template.HTML(mysql), "redis": template.HTML(redis),
+				"version": template.HTML(VERSION), "githash": template.HTML(GITHASH)})
 		} else {
 			c.String(400, "index err.")
 		}

+ 8 - 0
main.go

@@ -2,6 +2,7 @@ package main
 
 import (
 	"context"
+	"mtp2_if/controllers/other"
 	"net/http"
 	"os"
 	"os/signal"
@@ -36,6 +37,9 @@ type cmdLine struct {
 	StrCmd []string
 }
 
+var _VERSION_ = "default"
+var _GITHASH_ = "default"
+
 // IsInit 是否初始化某项, 如 IsInit("redis")
 func (r *cmdLine) IsInit(item string) bool {
 	if len(r.StrCmd) <= 1 {
@@ -73,6 +77,10 @@ func main() {
 		return
 	}
 
+	logger.GetLogger().Debugf("server version:%v", _VERSION_)
+	logger.GetLogger().Debugf("server git hash:%v", _GITHASH_)
+	other.VERSION, other.GITHASH = _VERSION_, _GITHASH_
+
 	if cmd.IsInit("oracle") {
 		// 初始化数据库引擎
 		err = db.InitDbEngine()