```
refactor(config): 移除登录端口配置和相关功能 移除LoginPort配置项,注释掉相关代码逻辑 feat(admin): 添加版本查询接口 新增Version接口用于获取当前版本信息 refactor(login): 禁用注册服务 注释掉reg()函数调用,禁用登录相关的注册服务 refactor(deploy): 更新文件下载逻辑 修改自动化部署流程中的文件下载地址,使用新的配置域名 chore(utils): 添加最新逻辑文件获取工具 添加utils.GetLatestLogicFile方法用于获取最新的逻辑文件 ```
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -45,3 +45,4 @@ public/logic-linux-amd64
|
||||
public/login-linux-amd64
|
||||
|
||||
public/login-login-linux-amd64
|
||||
public/logic_linux-amd64_1
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
|
||||
// cool config
|
||||
type sConfig struct {
|
||||
AutoMigrate bool `json:"auto_migrate,omitempty"` // 是否自动创建表
|
||||
Eps bool `json:"eps,omitempty"` // 是否开启eps
|
||||
File *file `json:"file,omitempty"` // 文件上传配置
|
||||
Name string `json:"name"` // 项目名称
|
||||
LoginPort string `json:"port"`
|
||||
AutoMigrate bool `json:"auto_migrate,omitempty"` // 是否自动创建表
|
||||
Eps bool `json:"eps,omitempty"` // 是否开启eps
|
||||
File *file `json:"file,omitempty"` // 文件上传配置
|
||||
Name string `json:"name"` // 项目名称
|
||||
// LoginPort string `json:"port"`
|
||||
GameOnlineID uint16 `json:"port_bl"` //这个是命令行输入的参数
|
||||
ServerInfo ServerList
|
||||
|
||||
@@ -70,9 +70,9 @@ func newConfig() *sConfig {
|
||||
AutoMigrate: GetCfgWithDefault(ctx, "blazing.autoMigrate", g.NewVar(false)).Bool(),
|
||||
Name: GetCfgWithDefault(ctx, "server.name", g.NewVar("")).String(),
|
||||
|
||||
Eps: GetCfgWithDefault(ctx, "blazing.eps", g.NewVar(false)).Bool(),
|
||||
LoginPort: string(GetCfgWithDefault(ctx, "server.port", g.NewVar("8080")).String()),
|
||||
Address: GetCfgWithDefault(ctx, "server.address", g.NewVar("8080")).String(),
|
||||
Eps: GetCfgWithDefault(ctx, "blazing.eps", g.NewVar(false)).Bool(),
|
||||
// LoginPort: string(GetCfgWithDefault(ctx, "server.port", g.NewVar("8080")).String()),
|
||||
Address: GetCfgWithDefault(ctx, "server.address", g.NewVar("8080")).String(),
|
||||
//GamePort: GetCfgWithDefault(ctx, "server.game", g.NewVar("8080")).Uint64s(),
|
||||
|
||||
File: &file{
|
||||
|
||||
59
common/utils/file.go
Normal file
59
common/utils/file.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetLatestLogicFile 遍历指定目录,返回以logic_为前缀的最新修改文件路径
|
||||
// dirPath: 目标目录路径(绝对路径或相对路径均可)
|
||||
func GetLatestLogicFile(dirPath string) (string, error) {
|
||||
// 1. 读取目录下所有文件/目录项
|
||||
entries, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("读取目录失败: %w", err)
|
||||
}
|
||||
|
||||
var (
|
||||
latestFile string // 记录最新文件的路径
|
||||
latestModTime fs.FileInfo // 记录最新文件的文件信息(用于对比时间)
|
||||
)
|
||||
|
||||
// 2. 遍历所有目录项,筛选并对比
|
||||
for _, entry := range entries {
|
||||
// 跳过目录,只处理普通文件
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
// 筛选以logic_开头的文件
|
||||
filename := entry.Name()
|
||||
if !strings.HasPrefix(filename, "logic_") {
|
||||
continue
|
||||
}
|
||||
|
||||
// 3. 获取文件的完整路径和详细信息(包含修改时间)
|
||||
fileFullPath := filepath.Join(dirPath, filename)
|
||||
fileInfo, err := os.Stat(fileFullPath)
|
||||
if err != nil {
|
||||
fmt.Printf("获取文件[%s]信息失败,跳过: %v\n", fileFullPath, err)
|
||||
continue
|
||||
}
|
||||
|
||||
// 4. 对比修改时间,更新最新文件记录
|
||||
if latestModTime == nil || fileInfo.ModTime().After(latestModTime.ModTime()) {
|
||||
latestFile = filename
|
||||
latestModTime = fileInfo
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 处理无符合条件文件的情况
|
||||
if latestFile == "" {
|
||||
return "", fmt.Errorf("目录[%s]下无符合条件的logic_前缀文件", dirPath)
|
||||
}
|
||||
|
||||
return latestFile, nil
|
||||
}
|
||||
@@ -35,7 +35,7 @@ var (
|
||||
panic(err)
|
||||
}
|
||||
//go robot()
|
||||
go reg()
|
||||
//go reg()
|
||||
s := g.Server()
|
||||
s.Use(Limiter, ghttp.MiddlewareHandlerResponse)
|
||||
s.EnableAdmin()
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"blazing/common/socket"
|
||||
"blazing/cool"
|
||||
"blazing/logic/controller"
|
||||
// var defaultPort = gconv.Int(cool.Config.LoginPort) //读入默认的端口
|
||||
// func reg() {
|
||||
// // go rpc.StartServer()
|
||||
// controller.Init(false)
|
||||
// //go rpcserver() //对login tcp启动
|
||||
// //ants.Submit(rpcserver)
|
||||
// socket.NewServer(
|
||||
// socket.WithCORS(),
|
||||
// socket.WithPort(defaultPort),
|
||||
// ).Boot()
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var defaultPort = gconv.Int(cool.Config.LoginPort) //读入默认的端口
|
||||
func reg() {
|
||||
// go rpc.StartServer()
|
||||
controller.Init(false)
|
||||
//go rpcserver() //对login tcp启动
|
||||
//ants.Submit(rpcserver)
|
||||
socket.NewServer(
|
||||
socket.WithCORS(),
|
||||
socket.WithPort(defaultPort),
|
||||
).Boot()
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -1 +1,21 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type CurVersionReq struct {
|
||||
g.Meta `path:"/version" method:"POST"`
|
||||
Authorization string `json:"Authorization" in:"header"`
|
||||
}
|
||||
|
||||
// Logout BaseCommLogout 方法
|
||||
func (c *BaseCommController) Version(ctx context.Context, req *CurVersionReq) (res *cool.BaseRes, err error) {
|
||||
filename, _ := utils.GetLatestLogicFile("public")
|
||||
res = cool.Ok(filename)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
config "blazing/modules/config/service"
|
||||
"bufio"
|
||||
@@ -148,13 +150,18 @@ func (s *ServerHandler) executeScript(scriptContent, scriptName string) (string,
|
||||
return strings.TrimSpace(output), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerHandler) executeFullDeployment() error {
|
||||
s.sendTerminalOutput(s.session.WebSocket, "开始执行完整自动化部署流程...")
|
||||
|
||||
// 1. 获取并校验下载链接
|
||||
filename := config.NewServerService().GetFile()
|
||||
fileURL := "http://sun.72wo.cn/" + filename
|
||||
// filename := config.NewServerService().GetFile()
|
||||
filename, _ := utils.GetLatestLogicFile("public")
|
||||
// fileURL := "http://sun.72wo.cn/" + filename
|
||||
fileURL := "http://" + cool.Config.File.Domain + cool.Config.Address + "/" + filename
|
||||
|
||||
fileURL = strings.TrimSpace(fileURL)
|
||||
fmt.Println("更新地址", fileURL)
|
||||
if fileURL == "" {
|
||||
return fmt.Errorf("下载链接为空")
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user