forked from mtusi2026/mtusi2026lab3
feat:level4
This commit is contained in:
@@ -50,7 +50,7 @@ func main() {
|
||||
|
||||
sessions := domain.NewSessionStore(store, cache, cfg.SessionTTL)
|
||||
handler := &api.Handler{Store: store, Sessions: sessions}
|
||||
router := api.NewRouter(handler)
|
||||
router := api.NewRouter(handler, cfg.InstanceID)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||
@@ -66,6 +66,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
log.Printf("messenger listening on %s (env=%s, session_ttl=%s)", srv.Addr, cfg.Env, cfg.SessionTTL)
|
||||
log.Printf("instance_id=%s", cfg.InstanceID)
|
||||
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
@@ -73,7 +74,7 @@ func main() {
|
||||
|
||||
<-stop
|
||||
log.Println("shutting down...")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
_ = srv.Shutdown(ctx)
|
||||
log.Println("stopped")
|
||||
|
||||
Reference in New Issue
Block a user