()
| 20 | } |
| 21 | |
| 22 | func stop() { |
| 23 | initDaemon() |
| 24 | if pid == -1 { |
| 25 | log.Info("Seems not have been started. Try use `openlist start` to start server.") |
| 26 | return |
| 27 | } |
| 28 | process, err := os.FindProcess(pid) |
| 29 | if err != nil { |
| 30 | log.Errorf("failed to find process by pid: %d, reason: %v", pid, process) |
| 31 | return |
| 32 | } |
| 33 | err = process.Signal(syscall.SIGTERM) |
| 34 | if err != nil { |
| 35 | log.Errorf("failed to terminate process %d: %v", pid, err) |
| 36 | } else { |
| 37 | log.Info("terminated process: ", pid) |
| 38 | } |
| 39 | err = os.Remove(pidFile) |
| 40 | if err != nil { |
| 41 | log.Errorf("failed to remove pid file") |
| 42 | } |
| 43 | pid = -1 |
| 44 | } |
| 45 | |
| 46 | func init() { |
| 47 | RootCmd.AddCommand(StopCmd) |
no test coverage detected