- Added signal.NotifyContext for modern signal handling in cmd/server/main.go - Implemented BaseContext for proper context propagation to HTTP handlers - Added readiness drain delay before shutdown for graceful degradation - Fixed PID detection in start-server.sh to target actual server process - Added Logging.JSON configuration option with DLC_LOGGING_JSON environment variable - Created comprehensive test script that validates entire server lifecycle - Updated documentation with JSON logging configuration examples - All shutdown logs now appear correctly in JSON format - Server terminates gracefully on SIGTERM with proper log flushing The graceful shutdown implementation follows VictoriaMetrics best practices: 1. Catches termination signals (SIGTERM, SIGINT) 2. Stops accepting new requests but allows ongoing requests to complete 3. Waits for active requests to finish within configured timeout 4. Releases resources and performs cleanup 5. Logs all shutdown steps for observability Test script validates: - Server startup and API functionality - Graceful shutdown sequence - JSON log format validation - Complete log sequence verification - Proper signal handling and context propagation Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
30 lines
831 B
YAML
30 lines
831 B
YAML
# DanceLessonsCoach Configuration Example
|
|
# This file shows the available configuration options
|
|
# You can use this as a template for your own configuration
|
|
|
|
# Server configuration
|
|
server:
|
|
# Host address to bind to (default: "0.0.0.0")
|
|
host: "0.0.0.0"
|
|
|
|
# Port to listen on (default: 8080)
|
|
port: 8080
|
|
|
|
# Shutdown configuration
|
|
shutdown:
|
|
# Timeout duration for graceful shutdown (default: 30s)
|
|
# Format: number + unit (s, m, h)
|
|
timeout: 30s
|
|
|
|
# Logging configuration
|
|
logging:
|
|
# Enable JSON output for structured logging (default: false)
|
|
# When true, logs are output in JSON format instead of console format
|
|
json: false
|
|
|
|
# Environment Variables
|
|
# You can also configure via environment variables with DLC_ prefix:
|
|
# DLC_SERVER_HOST=0.0.0.0
|
|
# DLC_SERVER_PORT=8080
|
|
# DLC_SHUTDOWN_TIMEOUT=30s
|
|
# DLC_LOGGING_JSON=false |