Skip to content

Commit

Permalink
Beta52 (#121)
Browse files Browse the repository at this point in the history
* beta9

* beta11

* beta11

* beta13

* beta12

* beta13

* beta15

* beta16

* beta17

* beta18

* beta19

* beta20

* beta21

* add_playermanager_api

* beta22

* beta23

* beta24

* beta25

* beta26

* beta27

* beta28

* beta28

* beta29

* beta30

* beta31

* beta32

* beta33

* beta34

* beta35

* beta35

* beta36

* beta37

* beta38

* beta39

* beta40

* beta41

* beta41

* beat43

* beta45

* beta45

* beta46

* beta50

* beta51

* beta52
  • Loading branch information
Hoshinonyaruko authored Mar 3, 2024
1 parent 0c389d1 commit cb3e6cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/hoshinonyaruko/palworld-go/bot"
"github.com/hoshinonyaruko/palworld-go/config"
"github.com/hoshinonyaruko/palworld-go/status"
"github.com/hoshinonyaruko/palworld-go/sys"
"github.com/hoshinonyaruko/palworld-go/tool"
"github.com/hoshinonyaruko/palworld-go/webui"
Expand Down Expand Up @@ -115,6 +116,8 @@ func main() {
fmt.Println("PalServer.exe exists in the current directory.")
}
}
//还原状态
status.SetManualServerShutdown(false)

// 设置监控和自动重启
supervisor := NewSupervisor(jsonconfig)
Expand Down
44 changes: 27 additions & 17 deletions sys/restart_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,34 @@ func RestartService(config config.Config) {
if config.WorldSettings.RconEnabled {
args = append(args, "-rcon")
}

args = append(args, config.ServerOptions...) // 添加GameWorldSettings参数

// 执行启动命令
log.Printf("启动命令: %s %s", exePath, strings.Join(args, " "))

cmd := exec.Command(exePath, args...)
cmd.Dir = config.GamePath // 设置工作目录为游戏路径

// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
// 添加GameWorldSettings参数
args = append(args, config.ServerOptions...)

if config.GameService && config.GameServiceName != "" {
cmd := exec.Command("sudo", "systemctl", "restart", config.GameServiceName)
// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
} else {
log.Printf("Game server restarted successfully")
}
} else {
log.Printf("Game server restarted successfully")
// 执行启动命令
log.Printf("启动命令: %s %s", exePath, strings.Join(args, " "))

cmd := exec.Command(exePath, args...)
cmd.Dir = config.GamePath // 设置工作目录为游戏路径

// 启动进程
if err := cmd.Start(); err != nil {
log.Printf("Failed to restart game server: %v", err)
} else {
log.Printf("Game server restarted successfully")
}

// 获取并打印 PID
log.Printf("Game server started successfully with PID %d", cmd.Process.Pid)
status.SetGlobalPid(cmd.Process.Pid)
}

// 获取并打印 PID
log.Printf("Game server started successfully with PID %d", cmd.Process.Pid)
status.SetGlobalPid(cmd.Process.Pid)

}

0 comments on commit cb3e6cf

Please sign in to comment.