Bound each shutdown stage by the stop deadline (closes #100)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Shutdown passes its context to every stage: the streamer, the four handlers, the WHOIS fetcher, the database maintainer and the HTTP server each stop waiting when it ends. A handler then skips its last write and logs how many updates it did not write, and the HTTP server closes the connections still open. The database is checkpointed and closed last, and left open once the deadline has passed, since a write may still hold it. The stop hook gives Shutdown 8 seconds and fx 9, inside the 10 seconds upaas and docker stop allow, so a stop signal exits 0. Model: opus-5-5
This commit is contained in:
@@ -109,7 +109,9 @@ func (s *Server) Start(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop gracefully stops the HTTP server
|
||||
// Stop stops the HTTP server. It waits, until ctx ends, for the requests in
|
||||
// progress to finish, and then closes the connections of those still running
|
||||
// and returns ctx's error.
|
||||
func (s *Server) Stop(ctx context.Context) error {
|
||||
if s.srv == nil {
|
||||
return nil
|
||||
@@ -117,7 +119,12 @@ func (s *Server) Stop(ctx context.Context) error {
|
||||
|
||||
s.logger.Info("Stopping HTTP server")
|
||||
|
||||
return s.srv.Shutdown(ctx)
|
||||
err := s.srv.Shutdown(ctx)
|
||||
if err != nil {
|
||||
return errors.Join(err, s.srv.Close())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetASNFetcher sets the ASN WHOIS fetcher for on-demand lookups.
|
||||
|
||||
Reference in New Issue
Block a user