Stop stops the running Syncthing process. If the process was logging to a local file (set by LogTo), the log file will be opened and checked for panics and data races. The presence of either will be signalled in the form of a returned error.
()
| 138 | // panics and data races. The presence of either will be signalled in the form |
| 139 | // of a returned error. |
| 140 | func (p *Process) Stop() (*os.ProcessState, error) { |
| 141 | select { |
| 142 | case <-p.stopped: |
| 143 | return p.cmd.ProcessState, p.stopErr |
| 144 | default: |
| 145 | } |
| 146 | |
| 147 | if _, err := p.Post("/rest/system/shutdown", nil); err != nil && !errors.Is(err, io.ErrUnexpectedEOF) { |
| 148 | // Unexpected EOF is somewhat expected here, as we may exit before |
| 149 | // returning something sensible. |
| 150 | return nil, err |
| 151 | } |
| 152 | |
| 153 | <-p.stopped |
| 154 | |
| 155 | return p.cmd.ProcessState, p.stopErr |
| 156 | } |
| 157 | |
| 158 | // Stopped returns a channel that will be closed when Syncthing has stopped. |
| 159 | func (p *Process) Stopped() chan struct{} { |