Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #34 from kasidej/fix/stop-process
Browse files Browse the repository at this point in the history
fix(cleanup): Shutdown http server to stop process
  • Loading branch information
Roverr authored Feb 18, 2020
2 parents 554457b + c19826b commit 2b32278
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -48,8 +49,17 @@ func main() {
MaxAge: config.CORS.MaxAge,
}).Handler(router)
}
logrus.Infof("rtsp-stream transcoder started on %d | MainProcess", config.Port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), handler))
srv := &http.Server{
Addr: fmt.Sprintf(":%d", config.Port),
Handler: handler,
}
go func() {
logrus.Infof("rtsp-stream transcoder started on %d | MainProcess", config.Port)
log.Fatal(srv.ListenAndServe())
}()
<-done
if err := srv.Shutdown(context.Background()); err != nil {
log.Printf("HTTP server Shutdown: %v", err)
}
os.Exit(0)
}

0 comments on commit 2b32278

Please sign in to comment.