8 Revize c7da010f01 ... be2884f48b

Autor SHA1 Zpráva Datum
  makeyangcom be2884f48b 1.0.0 před 8 měsíci
  makeyangcom 76ab269a40 1.0.0 před 8 měsíci
  makeyangcom acb42aaf1a 1.0.0 před 8 měsíci
  makeyangcom 125e13f9bd Merge branch 'main' of github.com:makeryangcom/Engine2D před 8 měsíci
  makeyangcom 1e681e7ca3 1.0.0 před 8 měsíci
  makeryangcom 05930cff8f 1.0.0 před 8 měsíci
  makeyangcom 7a10923d48 1.0.0 před 8 měsíci
  makeyangcom 02dd25ec67 1.0.0 před 8 měsíci

+ 13 - 5
server/framework/config/config.go

@@ -1,22 +1,26 @@
 /**
- ******************************************************************************
- * @file    config.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    config.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package Config
 
 import "time"
 
+// Get 定义系统配置模块的调用指针
 var Get = &config{}
 
+// 声明系统配置模块数据结构体
 type config struct {
 	Service  service  `json:"service"`
 	Database database `json:"database"`
 	Hash     hash     `json:"hash"`
 }
 
+// 声明系统配置模块的服务器配置数据结构体
 type service struct {
 	Mode         string        `json:"mode"`
 	HttpPort     int           `json:"http_port"`
@@ -24,6 +28,7 @@ type service struct {
 	WriteTimeout time.Duration `json:"write_timeout"`
 }
 
+// 声明系统配置模块的数据库配置数据结构体
 type database struct {
 	Type     string `json:"type"`
 	User     string `json:"user"`
@@ -32,11 +37,14 @@ type database struct {
 	Name     string `json:"name"`
 }
 
+// 声明系统配置模块的HASH加密配置数据结构体
 type hash struct {
 	Salt string `json:"salt"`
 }
 
+// Init 初始化系统配置
 func Init() {
+
 	Get.Service.Mode = "debug"
 	Get.Service.HttpPort = 7000
 	Get.Service.ReadTimeout = 60 * time.Second

+ 0 - 18
server/framework/controller/ping/ping.go

@@ -1,18 +0,0 @@
-/**
- ******************************************************************************
- * @file    ping.go
- * @author  MakerYang
- ******************************************************************************
- */
-
-package PingController
-
-import (
-	"Game/framework/utils"
-	"github.com/gin-gonic/gin"
-)
-
-func Ping(c *gin.Context) {
-	Utils.Success(c, Utils.EmptyData{})
-	return
-}

+ 9 - 5
server/framework/database/database.go

@@ -1,9 +1,10 @@
 /**
- ******************************************************************************
- * @file    database.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    database.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package Database
 
@@ -17,14 +18,17 @@ import (
 	"time"
 )
 
+// Get 定义数据库模块的调用指针
 var Get *gorm.DB
 
+// DefaultField 声明数据库默认字段
 type DefaultField struct {
 	CreateAt int `gorm:"Column:create_at" json:"create_at"`
 	UpdateAt int `gorm:"Column:update_at" json:"update_at"`
 	DeleteAt int `gorm:"Column:delete_at" json:"delete_at"`
 }
 
+// Init 初始化数据库连接
 func Init() {
 
 	var err error

+ 16 - 5
server/framework/database/interface.go → server/framework/database/function.go

@@ -1,9 +1,10 @@
 /**
- ******************************************************************************
- * @file    interface.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    function.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package Database
 
@@ -12,53 +13,63 @@ import (
 	"time"
 )
 
+// Base 声明数据库基础数据结构体
 type Base struct {
 	TableName string
 }
 
+// New 实例化数据表
 func New(table string) *Base {
 	return &Base{
 		TableName: table,
 	}
 }
 
+// CreateData 创建数据
 func (base *Base) CreateData(data interface{}) error {
 	err := Get.Table(base.TableName).Create(data).Error
 	return err
 }
 
+// UpdateData 更新数据
 func (base *Base) UpdateData(query interface{}, data map[string]interface{}) error {
 	data["update_at"] = time.Now().Unix()
 	err := Get.Table(base.TableName).Where(query).Updates(data).Error
 	return err
 }
 
+// ExprData 更新数值类字段值
 func (base *Base) ExprData(query interface{}, field string, operation string, data int) error {
 	err := Get.Table(base.TableName).Where(query).Update(field, gorm.Expr(field+" "+operation+" ?", data)).Error
 	return err
 }
 
+// GetData 读取一条数据
 func (base *Base) GetData(dataStruct interface{}, query interface{}, order string) error {
 	err := Get.Table(base.TableName).Where(query).Order(order).First(dataStruct).Error
 	return err
 }
 
+// ListData 读取多条数据
 func (base *Base) ListData(dataStruct interface{}, query interface{}, order string, limit int) error {
 	err := Get.Table(base.TableName).Where(query).Order(order).Limit(limit).Find(dataStruct).Error
 	return err
 }
 
+// PageData 读取分页数据
 func (base *Base) PageData(dataStruct interface{}, query interface{}, order string, limit int, page int) error {
 	err := Get.Table(base.TableName).Where(query).Order(order).Limit(limit).Offset(page * limit).Find(dataStruct).Error
 	return err
 }
 
+// CountData 获取数据总数
 func (base *Base) CountData(query interface{}) (int, error) {
 	count := 0
 	err := Get.Table(base.TableName).Where(query).Count(&count).Error
 	return count, err
 }
 
+// DeleteData 删除数据
 func (base *Base) DeleteData(dataStruct interface{}, query interface{}) error {
 	err := Get.Table(base.TableName).Where(query).Delete(dataStruct).Error
 	return err

+ 9 - 8
server/framework/framework.go

@@ -1,16 +1,17 @@
 /**
- ******************************************************************************
- * @file    framework.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    framework.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package Framework
 
 import (
 	"Game/framework/config"
-	"Game/framework/controller"
 	"Game/framework/database"
+	"Game/framework/interface"
 )
 
 func Init() {
@@ -18,6 +19,6 @@ func Init() {
 	Config.Init()
 	// 初始化数据库
 	Database.Init()
-	// 初始化控制器
-	Controller.Init()
+	// 初始化接口路由
+	Interface.Init()
 }

+ 14 - 8
server/framework/controller/controller.go → server/framework/interface/interface.go

@@ -1,15 +1,16 @@
 /**
- ******************************************************************************
- * @file    controller.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    interface.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
-package Controller
+package Interface
 
 import (
 	"Game/framework/config"
-	"Game/framework/controller/ping"
+	"Game/framework/interface/ping"
 	"context"
 	"fmt"
 	"github.com/gin-gonic/gin"
@@ -21,17 +22,22 @@ import (
 	"time"
 )
 
+// 接口路由
 func router() *gin.Engine {
+
 	router := gin.New()
 
 	gin.SetMode(Config.Get.Service.Mode)
 
-	router.GET("/ping", PingController.Ping)
+	// 健康检查接口
+	router.GET("/ping", PingInterface.Ping)
 
 	return router
 }
 
+// Init 接口初始化
 func Init() {
+
 	routers := router()
 
 	var HttpServer = &http.Server{

+ 21 - 0
server/framework/interface/ping/ping.go

@@ -0,0 +1,21 @@
+/**
+#*****************************************************************************
+# @file    ping.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
+package PingInterface
+
+import (
+	"Game/framework/utils"
+	"github.com/gin-gonic/gin"
+)
+
+// Ping 健康检查接口
+func Ping(c *gin.Context) {
+
+	Utils.Success(c, Utils.Empty{})
+	return
+}

+ 11 - 0
server/framework/utils/empty.go

@@ -0,0 +1,11 @@
+/**
+#*****************************************************************************
+# @file    empty.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
+package Utils
+
+type Empty struct{}

+ 0 - 3
server/framework/utils/empty_data.go

@@ -1,3 +0,0 @@
-package Utils
-
-type EmptyData struct{}

+ 8 - 0
server/framework/utils/hashids.go → server/framework/utils/hash.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    hash.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (

+ 8 - 36
server/framework/utils/header.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    header.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import "strings"
@@ -11,39 +19,3 @@ func CheckUserAgent(userAgent string) bool {
 
 	return Status
 }
-
-func CheckGame(token string) (int, int, bool) {
-	Status := false
-	GameId := 0
-	GameAccountId := 0
-
-	if token != "" {
-		tokenMap, _ := DecodeId(128, token)
-		if len(tokenMap) == 2 {
-			GameId = tokenMap[0]
-			GameAccountId = tokenMap[1]
-			Status = true
-		}
-	}
-
-	if GameId == 0 || GameAccountId == 0 {
-		Status = false
-	}
-
-	return GameId, GameAccountId, Status
-}
-
-func CheckUser(token string) (int, bool) {
-	Status := false
-	Uid := 0
-
-	if token != "" {
-		tokenMap, _ := DecodeId(32, token)
-		if len(tokenMap) == 3 {
-			Uid = tokenMap[0]
-			Status = true
-		}
-	}
-
-	return Uid, Status
-}

+ 25 - 0
server/framework/utils/mail.go

@@ -0,0 +1,25 @@
+/**
+#*****************************************************************************
+# @file    mail.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
+package Utils
+
+import "gopkg.in/gomail.v2"
+
+func SendMail(to string, subject string, content string) bool {
+	status := true
+	mail := gomail.NewMessage()
+	mail.SetHeader("From", mail.FormatAddress("", ""))
+	mail.SetHeader("To", to)
+	mail.SetHeader("Subject", subject)
+	mail.SetBody("text/html", content)
+	send := gomail.NewDialer("smtp.qq.com", 587, "", "")
+	if err := send.DialAndSend(mail); err != nil {
+		status = false
+	}
+	return status
+}

+ 0 - 17
server/framework/utils/mailbox.go

@@ -1,17 +0,0 @@
-package Utils
-
-import "gopkg.in/gomail.v2"
-
-func SendMail(to string, subject string, content string) bool {
-	status := true
-	mail := gomail.NewMessage()
-	mail.SetHeader("From", mail.FormatAddress("open@wileho.com", "GEEKROS"))
-	mail.SetHeader("To", to)
-	mail.SetHeader("Subject", subject)
-	mail.SetBody("text/html", content)
-	send := gomail.NewDialer("smtp.qq.com", 587, "open@wileho.com", "")
-	if err := send.DialAndSend(mail); err != nil {
-		status = false
-	}
-	return status
-}

+ 0 - 27
server/framework/utils/markdown.go

@@ -1,27 +0,0 @@
-package Utils
-
-import (
-	"regexp"
-	"strings"
-)
-
-func FilterMarkdown(input string) string {
-	quoteBlockRegex := regexp.MustCompile(`^\s*>[ \t]*(.*)$`)
-	lines := strings.Split(input, "\n")
-	var quoteLines []string
-	for _, line := range lines {
-		if quoteBlockRegex.MatchString(line) {
-			match := quoteBlockRegex.FindStringSubmatch(line)
-			quoteLines = append(quoteLines, match[1])
-		}
-	}
-	return strings.Join(quoteLines, "")
-}
-
-func FilterSummary(input string, maxLength int) string {
-	text := strings.TrimSpace(input)
-	if len(text) <= maxLength {
-		return text
-	}
-	return text[:maxLength]
-}

+ 6 - 5
server/framework/utils/md5.go

@@ -1,9 +1,10 @@
 /**
- ******************************************************************************
- * @file    md5.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    md5.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package Utils
 

+ 8 - 0
server/framework/utils/order.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    order.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (

+ 8 - 59
server/framework/utils/phone.go

@@ -1,11 +1,14 @@
+/**
+#*****************************************************************************
+# @file    phone.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (
-	"bytes"
-	"encoding/json"
-	"io/ioutil"
-	"log"
-	"net/http"
 	"regexp"
 )
 
@@ -13,57 +16,3 @@ func MobileFormat(str string) string {
 	re, _ := regexp.Compile("(\\d{3})(\\d{6})(\\d{2})")
 	return re.ReplaceAllString(str, "$1******$3")
 }
-
-func SendMessage(form string, phone string, info string) bool {
-	status := true
-	if form == "" || phone == "" || info == "" {
-		status = false
-		return status
-	}
-	desc := ""
-	if form == "express" {
-		desc = "【GEEKROS】Hi," + info + " ,你在GEEKROS的订单已经发货,请留意快递信息,及时查收。"
-	}
-	if form == "account" {
-		desc = "【GEEKROS】你的验证码为:" + info + " ,有效期10分钟,工作人员绝不会索取此验证码,切勿告知他人。"
-	}
-
-	apiUrl := "https://smssh1.253.com/msg/v1/send/json"
-	params := make(map[string]interface{})
-	params["account"] = ""
-	params["password"] = ""
-	params["phone"] = phone
-	params["msg"] = desc
-	params["report"] = "false"
-
-	bytesData, err := json.Marshal(params)
-	if err != nil {
-		status = false
-		return status
-	}
-
-	reader := bytes.NewReader(bytesData)
-	request, err := http.NewRequest("POST", apiUrl, reader)
-	if err != nil {
-		status = false
-		return status
-	}
-
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
-	client := http.Client{}
-	resp, err := client.Do(request)
-	if err != nil {
-		status = false
-		return status
-	}
-
-	respBytes, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		status = false
-		return status
-	}
-
-	log.Println("[PhoneMessage]", string(respBytes))
-
-	return true
-}

+ 8 - 0
server/framework/utils/price.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    price.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import "fmt"

+ 8 - 0
server/framework/utils/rand.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    rand.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (

+ 64 - 37
server/framework/utils/return.go

@@ -1,9 +1,19 @@
+/**
+#*****************************************************************************
+# @file    return.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"log"
+	"math"
 	"net/http"
 	"os"
 	"strconv"
@@ -11,95 +21,112 @@ import (
 )
 
 type logData struct {
-	Timestamp       int64  `json:"timestamp"`
-	TimestampFormat string `json:"timestamp_format"`
-	ClientMethod    string `json:"client_method"`
-	ClientIp        string `json:"client_ip"`
-	ClientParameter string `json:"client_parameter"`
-	ServerParameter string `json:"server_parameter"`
-	ServerUrl       string `json:"server_url"`
-	ServerName      string `json:"server_name"`
-	ServerYear      string `json:"server_year"`
-	ServerMonth     string `json:"server_month"`
-	ServerDay       string `json:"server_day"`
-	ServerTime      string `json:"server_time"`
-	TimeLength      string `json:"time_length"`
+	ClientIp        string          `json:"client_ip"`
+	ClientMethod    string          `json:"client_method"`
+	ClientUrl       string          `json:"client_url"`
+	ClientSign      string          `json:"client_sign"`
+	ClientToken     string          `json:"client_token"`
+	ClientReferer   string          `json:"client_referer"`
+	ClientParameter clientParameter `json:"client_parameter"`
+	ServerParameter string          `json:"server_parameter"`
+	Date            string          `json:"date"`
+	Time            int64           `json:"time"`
+	Server          string          `json:"server"`
+	Length          string          `json:"length"`
+}
+
+type clientParameter struct {
+	Get  interface{} `json:"get"`
+	Post interface{} `json:"post"`
 }
 
-func recordLog(c *gin.Context, serverParameter string) {
+func requestLog(c *gin.Context, serverParameter string) {
+
 	data := &logData{}
-	data.Timestamp = time.Now().Unix()
-	data.TimestampFormat = time.Now().Format("2006-01-02 15:04:05")
+	data.Time = time.Now().Unix()
+	data.Date = time.Now().Format("2006-01-02 15:04:05")
 	data.ClientMethod = c.Request.Method
 	data.ClientIp = c.ClientIP()
+	data.ClientSign = c.Request.Header.Get("Client-Sign")
+	data.ClientToken = c.Request.Header.Get("Client-Token")
+	data.ClientReferer = c.Request.Header.Get("Client-Referer")
 	if data.ClientMethod == "GET" {
-		data.ClientParameter = c.Request.RequestURI
+		data.ClientParameter.Get = c.Request.URL.Query()
 	}
 	if data.ClientMethod == "POST" {
-		clientParam, err := json.Marshal(c.Request.PostForm)
-		if err != nil {
-			data.ClientParameter = ""
-		}
-		if err == nil {
-			data.ClientParameter = string(clientParam)
-		}
+		data.ClientParameter.Post = c.Request.PostForm
 	}
 	scheme := "http://"
 	if c.Request.TLS != nil {
 		scheme = "https://"
 	}
 	serverUrl := scheme + c.Request.Host + c.Request.URL.Path
+	data.ClientUrl = serverUrl
 	serverName, _ := os.Hostname()
-	data.ServerUrl = serverUrl
-	data.ServerName = serverName
-	data.ClientParameter = c.GetString("client_parameter")
+	data.Server = serverName
 	data.ServerParameter = serverParameter
-	data.ServerYear = time.Now().Format("2006")
-	data.ServerMonth = time.Now().Format("01")
-	data.ServerDay = time.Now().Format("02")
-	data.ServerTime = time.Now().Format("15:04:05")
-	data.TimeLength = strconv.FormatFloat(float64(time.Now().UnixNano())/1000000-c.GetFloat64("start_time"), 'f', 2, 64)
+
+	clientTimeStr := c.Request.Header.Get("Client-Time")
+	if clientTimeStr != "" {
+		clientTimeMs, _ := strconv.ParseInt(clientTimeStr, 10, 64)
+		serverTimeMs := time.Now().UnixNano() / 1e6
+		processingTimeMs := serverTimeMs - clientTimeMs
+		data.Length = fmt.Sprintf("%.3f", math.Abs(float64(processingTimeMs)/1000.0))
+	}
+
 	dataString, _ := json.Marshal(data)
 
-	log.Println("[Log]", string(dataString))
+	log.Println("[request]", string(dataString))
 }
 
 func Success(c *gin.Context, data interface{}) {
+
 	c.JSON(http.StatusOK, gin.H{
 		"code": 0,
 		"msg":  "success",
 		"data": data,
 	})
+
 	logJson, _ := json.Marshal(gin.H{"code": 0, "msg": "success", "data": data})
-	recordLog(c, string(logJson))
+
+	requestLog(c, string(logJson))
 }
 
 func Error(c *gin.Context, data interface{}) {
+
 	c.JSON(http.StatusOK, gin.H{
 		"code": 10000,
 		"msg":  "error",
 		"data": data,
 	})
+
 	logJson, _ := json.Marshal(gin.H{"code": 10000, "msg": "error", "data": data})
-	recordLog(c, string(logJson))
+
+	requestLog(c, string(logJson))
 }
 
 func Warning(c *gin.Context, code int, msg string, data interface{}) {
+
 	c.JSON(http.StatusOK, gin.H{
 		"code": code,
 		"msg":  msg,
 		"data": data,
 	})
+
 	logJson, _ := json.Marshal(gin.H{"code": code, "msg": msg, "data": data})
-	recordLog(c, string(logJson))
+
+	requestLog(c, string(logJson))
 }
 
 func AuthError(c *gin.Context, code int, msg string, data interface{}) {
+
 	c.JSON(http.StatusUnauthorized, gin.H{
 		"code": code,
 		"msg":  msg,
 		"data": data,
 	})
+
 	logJson, _ := json.Marshal(gin.H{"code": code, "msg": msg, "data": data})
-	recordLog(c, string(logJson))
+
+	requestLog(c, string(logJson))
 }

+ 8 - 0
server/framework/utils/time.go

@@ -1,3 +1,11 @@
+/**
+#*****************************************************************************
+# @file    time.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
+
 package Utils
 
 import (

+ 7 - 5
server/main.go

@@ -1,14 +1,16 @@
 /**
- ******************************************************************************
- * @file    main.go
- * @author  MakerYang
- ******************************************************************************
- */
+#*****************************************************************************
+# @file    main.go
+# @author  MakerYang(https://www.makeryang.com)
+# @statement 免费课程配套开源项目,任何形式收费均为盗版
+#*****************************************************************************
+*/
 
 package main
 
 import "Game/framework"
 
+// 程序启动口
 func main() {
 	// 初始化核心框架
 	Framework.Init()

+ 39 - 0
tools/help.sh

@@ -0,0 +1,39 @@
+#!/bin/sh
+
+set -e
+
+GRAY='\033[1;30m'
+GREEN='\033[0;32m'
+BLUE='\033[0;34m'
+YELLOW='\033[0;33m'
+
+# shellcheck disable=SC2039
+echo -e "${YELLOW}一些常用的命令脚本:${NC}"
+
+echo -e "${GRAY}查看所有服务状态${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo systemctl status server.service game.service${NC}"
+
+# shellcheck disable=SC2039
+echo -e "${GRAY}重启后端服务${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo systemctl restart server.service${NC}"
+# shellcheck disable=SC2039
+echo -e "${GRAY}重启游戏服务器${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo systemctl restart game.service${NC}"
+
+# shellcheck disable=SC2039
+echo -e "${GRAY}监听后端服务实时日志${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo journalctl -fu server.service${NC}"
+# shellcheck disable=SC2039
+echo -e "${GRAY}监听游戏服务器实时日志${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo journalctl -fu game.service${NC}"
+# shellcheck disable=SC2039
+
+echo -e "${GRAY}重启Nginx服务${NC}"
+# shellcheck disable=SC2039
+echo -e "${GREEN}sudo systemctl restart nginx.service${NC}"
+# shellcheck disable=SC2039

+ 1 - 0
tools/update.sh

@@ -6,6 +6,7 @@ set -e
 sudo cp -r ./tools/centos/* /
 
 # 复制后端服务到运行目录
+sudo rm -rf /data/wwwroot/server
 sudo cp -r ./server /data/wwwroot/
 
 # 创建游戏引擎服务端运行目录

+ 1 - 4
update.bat

@@ -1,5 +1,2 @@
 @echo off
-
-scp -r ./engine/release/server* root@172.21.245.0:/data/wwwroot/game/
-
-ssh root@172.21.245.0 "chmod +x /data/wwwroot/game/* && cd /opt/Engine2D && sudo ./tools/update.sh"
+scp -r ./engine/release/server* root@172.21.245.0:/data/wwwroot/game/

+ 3 - 0
wiki/course/0002.md

@@ -0,0 +1,3 @@
+## 第二课
+
+> 第一课时操作引导文档。