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:
commit
9b222a87fb
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user