新增自动迁移创建路由后重启

修改
- server/api/v1/sys_system.go
- server/config.yaml
- server/config/auto_code.go
- server/service/sys_auto_code.go
新增
- server/utils/reload.go
This commit is contained in:
songzhibin97
2021-05-12 11:53:52 +08:00
parent 8159aa1a88
commit 169205f132
5 changed files with 40 additions and 24 deletions

View File

@@ -5,10 +5,7 @@ import (
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"os"
"os/exec"
"runtime"
"strconv"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
@@ -54,13 +51,7 @@ func SetSystemConfig(c *gin.Context) {
// @Success 200 {string} string "{"code":0,"data":{},"msg":"重启系统成功"}"
// @Router /system/reloadSystem [post]
func ReloadSystem(c *gin.Context) {
if runtime.GOOS == "windows" {
response.FailWithMessage("系统不支持", c)
return
}
pid := os.Getpid()
cmd := exec.Command("kill", "-1", strconv.Itoa(pid))
err := cmd.Run()
err := utils.Reload()
if err != nil {
global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err))
response.FailWithMessage("重启系统失败", c)