1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-06-19 05:55:04 +08:00

Merge pull request #1689 from sgpublic/dev

fix: more compatible behavior and some fix for deamon pid
This commit is contained in:
wdvxdr1123 2022-09-13 20:49:47 +08:00 committed by GitHub
commit 9b222a87fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -55,10 +55,10 @@ func Main() {
switch {
case base.LittleH:
base.Help()
case base.LittleD:
server.Daemon()
case base.LittleWD != "":
base.ResetWorkingDir()
case base.LittleD:
server.Daemon()
}
base.Init()

View File

@ -140,7 +140,8 @@ func ResetWorkingDir() {
args = append(args, os.Args[i])
}
}
p, _ := filepath.Abs(os.Args[0])
ex, _ := os.Executable()
p, _ := filepath.Abs(ex)
_, err := os.Stat(p)
if !(err == nil || errors.Is(err, os.ErrExist)) {
log.Fatalf("重置工作目录时出现错误: 无法找到路径 %v", p)

View File

@ -5,6 +5,7 @@ package server
import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
@ -28,7 +29,9 @@ func Daemon() {
execArgs = append(execArgs, args[i])
}
proc := exec.Command(os.Args[0], execArgs...)
ex, _ := os.Executable()
p, _ := filepath.Abs(ex)
proc := exec.Command(p, execArgs...)
err := proc.Start()
if err != nil {
panic(err)