fix(server): drain scheduler on unexpected serve error before exit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -185,6 +185,12 @@ func main() {
|
||||
log.Printf("server stopped")
|
||||
case err := <-serveErr:
|
||||
if err != nil {
|
||||
// Unwind scheduler.Run via ctx.Done and wait for the in-flight
|
||||
// RunOnce to finish before exiting, so an unexpected serve error
|
||||
// mid-run doesn't kill the process during a check/notify write —
|
||||
// same hazard the ctx.Done branch above already guards against.
|
||||
stop()
|
||||
wg.Wait()
|
||||
log.Fatalf("server: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user