1
0

panel.go 402 B

1234567891011121314151617181920212223242526
  1. package service
  2. import (
  3. "os"
  4. "syscall"
  5. "time"
  6. "x-ui/logger"
  7. )
  8. type PanelService struct{}
  9. func (s *PanelService) RestartPanel(delay time.Duration) error {
  10. p, err := os.FindProcess(syscall.Getpid())
  11. if err != nil {
  12. return err
  13. }
  14. go func() {
  15. time.Sleep(delay)
  16. err := p.Signal(syscall.SIGHUP)
  17. if err != nil {
  18. logger.Error("failed to send SIGHUP signal:", err)
  19. }
  20. }()
  21. return nil
  22. }