close server on receiving signal (#4213)

This commit is contained in:
Jeffrey Morgan 2024-05-06 16:01:37 -07:00 committed by GitHub
parent af47413dba
commit 39d9d22ca3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -898,7 +898,12 @@ func RunServer(cmd *cobra.Command, _ []string) error {
return err
}
return server.Serve(ln)
err = server.Serve(ln)
if errors.Is(err, http.ErrServerClosed) {
return nil
}
return err
}
func initializeKeypair() error {

View file

@ -1041,6 +1041,7 @@ func Serve(ln net.Listener) error {
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-signals
srvr.Close()
done()
sched.unloadAllRunners()
gpu.Cleanup()