Restart the daemon, or start it if it's not yet running
()
| 74 | |
| 75 | // Restart the daemon, or start it if it's not yet running |
| 76 | func (d *daemon) Restart() { |
| 77 | d.Lock() |
| 78 | defer d.Unlock() |
| 79 | if d.ex == nil { |
| 80 | ex, err := shell.NewExecutor(d.shell, d.conf.Command, d.indir) |
| 81 | if err != nil { |
| 82 | d.log.Shout("Could not create executor: %s", err) |
| 83 | } |
| 84 | d.ex = ex |
| 85 | go d.Run() |
| 86 | } else { |
| 87 | d.log.Notice(">> sending signal %s", d.conf.RestartSignal) |
| 88 | err := d.ex.Signal(d.conf.RestartSignal) |
| 89 | if err != nil { |
| 90 | d.log.Warn( |
| 91 | "failed to send %s signal to %s: %v", d.conf.RestartSignal, d.conf.Command, err, |
| 92 | ) |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func (d *daemon) Shutdown(sig os.Signal) error { |
| 98 | d.log.Notice(">> stopping") |