Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ctrl+c shutdown for
serve-doc
(#297)
When the ctrl+c signal (SIGINT on unix) is received, we fire off a [`CancellationToken`](https://docs.rs/tokio-util/latest/tokio_util/sync/struct.CancellationToken.html), which: - gracefully shuts down the server process - shuts down the GC task, which triggers: - shuts down persistence task (which waits until every dirty doc is persisted to return) The mechanism for the GC process triggering the shut down of the persistence task is the `persistence_cancellation_token` which is fired when the GC task completes. However, in `serve-doc`, we only care about one doc so we don't GC inactive docs. This means the `persistence_cancellation_token` never fires in `serve-doc` mode. The fix is to simplify things: one `cancellation_token` is responsible for all three graceful shutdowns (server, GC task, and persistence task). When we cancel the GC task it simply breaks out of the loop, so there is no code in the GC task that must complete before we shut down the persistence task. (@rbtying please correct me if I'm missing something!)
- Loading branch information