feat: configure graceful shutdown window
This commit is contained in:
@@ -74,6 +74,7 @@ func run() error {
|
||||
ScheduleTickInterval: cfg.ScheduleTickInterval,
|
||||
RecoveryTickInterval: cfg.RecoveryTickInterval,
|
||||
BatchLimit: cfg.RuntimeBatchLimit,
|
||||
ShutdownTimeout: cfg.ShutdownTimeout,
|
||||
})
|
||||
metrics.RecordDatabase(db.Stats())
|
||||
}
|
||||
@@ -94,7 +95,7 @@ func run() error {
|
||||
httpserver.RegisterEventSubscriptions(server, eventService)
|
||||
httpserver.RegisterEventConsumers(server, eventHub)
|
||||
defer func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cfg.ShutdownTimeout)
|
||||
defer cancel()
|
||||
_ = eventHub.Shutdown(ctx)
|
||||
}()
|
||||
@@ -161,7 +162,7 @@ func run() error {
|
||||
}()
|
||||
defer func() { stopSchedules(); <-scheduleDone }()
|
||||
defer func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cfg.ShutdownTimeout)
|
||||
defer cancel()
|
||||
_ = hub.Shutdown(ctx)
|
||||
}()
|
||||
@@ -249,7 +250,7 @@ func run() error {
|
||||
slog.Info("Orbit metrics server starting", "metrics_address", metricsListener.Addr().String())
|
||||
}
|
||||
go func() { done <- server.Serve(listener) }()
|
||||
slog.Info("Orbit HTTP server starting", "address", listener.Addr().String(), "scope", "health, task, queue, schedule, subscription, workflow and Worker APIs", "node_id", node, "workflow_tick_interval", cfg.WorkflowTickInterval.String(), "schedule_tick_interval", cfg.ScheduleTickInterval.String(), "recovery_tick_interval", cfg.RecoveryTickInterval.String(), "runtime_batch_limit", cfg.RuntimeBatchLimit)
|
||||
slog.Info("Orbit HTTP server starting", "address", listener.Addr().String(), "scope", "health, task, queue, schedule, subscription, workflow and Worker APIs", "node_id", node, "workflow_tick_interval", cfg.WorkflowTickInterval.String(), "schedule_tick_interval", cfg.ScheduleTickInterval.String(), "recovery_tick_interval", cfg.RecoveryTickInterval.String(), "runtime_batch_limit", cfg.RuntimeBatchLimit, "shutdown_timeout", cfg.ShutdownTimeout.String())
|
||||
select {
|
||||
case err := <-done:
|
||||
if errors.Is(err, http.ErrServerClosed) {
|
||||
@@ -258,7 +259,7 @@ func run() error {
|
||||
return err
|
||||
case <-root.Done():
|
||||
readiness.BeginDrain()
|
||||
shutdown, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
shutdown, cancel := context.WithTimeout(context.Background(), cfg.ShutdownTimeout)
|
||||
defer cancel()
|
||||
if err := server.Shutdown(shutdown); err != nil {
|
||||
_ = server.Close()
|
||||
|
||||
Reference in New Issue
Block a user