(reason string)
| 76 | } |
| 77 | |
| 78 | func doShutdown(reason string) { |
| 79 | shutdownOnce.Do(func() { |
| 80 | log.Printf("shutting down: %s\n", reason) |
| 81 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 82 | defer cancelFn() |
| 83 | go blockcontroller.StopAllBlockControllersForShutdown() |
| 84 | shutdownActivityUpdate() |
| 85 | sendTelemetryWrapper() |
| 86 | // TODO deal with flush in progress |
| 87 | clearTempFiles() |
| 88 | filestore.WFS.FlushCache(ctx) |
| 89 | watcher := wconfig.GetWatcher() |
| 90 | if watcher != nil { |
| 91 | watcher.Close() |
| 92 | } |
| 93 | time.Sleep(500 * time.Millisecond) |
| 94 | log.Printf("shutdown complete\n") |
| 95 | os.Exit(0) |
| 96 | }) |
| 97 | } |
| 98 | |
| 99 | // watch stdin, kill server if stdin is closed |
| 100 | func stdinReadWatch() { |
no test coverage detected