1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

feather: faststart

This commit is contained in:
Ink-33 2020-11-17 00:24:25 +08:00
parent 990e7744a3
commit 28f1594539
No known key found for this signature in database
GPG Key ID: 5D8B1D036EFB0D2E

11
main.go
View File

@ -98,7 +98,7 @@ func init() {
func main() { func main() {
console := bufio.NewReader(os.Stdin) console := bufio.NewReader(os.Stdin)
var strKey string var strKey string
var isRestart bool = false var isFastStart bool = false
arg := os.Args arg := os.Args
fmt.Println(arg) fmt.Println(arg)
if len(arg) > 1 { if len(arg) > 1 {
@ -116,8 +116,8 @@ func main() {
b = append(b, 13, 10) b = append(b, 13, 10)
strKey = string(b[:]) strKey = string(b[:])
} }
case "restart": case "faststart":
isRestart = true isFastStart = true
} }
} }
} }
@ -256,7 +256,7 @@ func main() {
key := md5.Sum([]byte(strKey)) key := md5.Sum([]byte(strKey))
conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:]) conf.Password = DecryptPwd(conf.PasswordEncrypted, key[:])
} }
if !isRestart { if !isFastStart {
log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.") log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.")
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
} }
@ -464,7 +464,7 @@ func restart(Args []string) {
if err != nil { if err != nil {
log.Errorf("重启失败:%s", err.Error()) log.Errorf("重启失败:%s", err.Error())
} }
Args = append([]string{"/c", "start ", path, "restart"}, Args[1:]...) Args = append([]string{"/c", "start ", path, "faststart"}, Args[1:]...)
cmd = &exec.Cmd{ cmd = &exec.Cmd{
Path: "cmd.exe", Path: "cmd.exe",
Args: Args, Args: Args,
@ -472,6 +472,7 @@ func restart(Args []string) {
Stdout: os.Stdout, Stdout: os.Stdout,
} }
} else { } else {
Args = append(Args, "faststart")
cmd = &exec.Cmd{ cmd = &exec.Cmd{
Path: Args[0], Path: Args[0],
Args: Args, Args: Args,