re-init
暂存 tmp
This commit is contained in:
22
core/restart.go
Normal file
22
core/restart.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func RestartSelf() {
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
panic("获取可执行文件路径失败: " + err.Error())
|
||||
}
|
||||
|
||||
args := os.Args
|
||||
env := os.Environ()
|
||||
|
||||
// 使用exec替换当前进程为新的进程
|
||||
err = syscall.Exec(executable, args, env)
|
||||
if err != nil {
|
||||
panic("重启失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user