reload.go 266 B

123456789101112131415161718
  1. package utils
  2. import (
  3. "errors"
  4. "os"
  5. "os/exec"
  6. "runtime"
  7. "strconv"
  8. )
  9. func Reload() error {
  10. if runtime.GOOS == "windows" {
  11. return errors.New("系统不支持")
  12. }
  13. pid := os.Getpid()
  14. cmd := exec.Command("kill", "-1", strconv.Itoa(pid))
  15. return cmd.Run()
  16. }