Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Laravel Advanced & Architecture 8-10 Years (Tech Lead) Hard Production Scenario

How do you handle graceful worker restarts in Kubernetes / Docker for Laravel Queues and Octane?

Real-World Scenario / Incident Description

During Kubernetes rolling deployments, pods received `SIGTERM` and immediately died, terminating active payment processing jobs mid-flight and corrupting order status.

95 views • Updated 1 month ago

Graceful Termination Workflow

  1. Catch SIGTERM in worker: In Kubernetes, set terminationGracePeriodSeconds: 120.
  2. Supervisor Configuration: Set stopwaitsecs = 120 so Supervisor gives workers up to 2 minutes to finish processing current job before force killing (SIGKILL).
  3. Queue Worker Command:
    php artisan queue:work --stop-when-empty --max-time=3600 --timeout=90
    
Related Concepts: #Kubernetes #Docker #Graceful Shutdown #SIGTERM #DevOps