Merge pull request #1390 from iofq/master

Make HTTP server wait for tasks before shutdown
This commit is contained in:
André Roth authored and GitHub committed 2024-11-10 15:38:47 +01:00
commit 147955c682
4 files changed
+17 -5

No files matched your search

+2
View File
@@ -65,6 +65,8 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
signal.Notify(sigchan, syscall.SIGINT, syscall.SIGTERM)
go (func() {
if _, ok := <-sigchan; ok {
fmt.Printf("\nShutdown signal received, waiting for background tasks...\n")
context.TaskList().Wait()
server.Shutdown(stdcontext.Background())
}
})()