Laravel scheduler terminating your processes (sending SIGKILL signal)
Aug 09 / 1 min read
Language Mismatch Disclaimer: Please be aware that the language of this article may not match the language settings of your browser or device.
Do you want to read articles in English instead ?
It's likely that Supervisor is terminating processes that run longer than 10 seconds, which is the default value for stopwaitsecs
.
Context
We have a scheduled command that runs every 5 minutes to:
- Process data from two APIs
- Combine the data (with additional processing)
- Send it to a third API
This involves:
- Approximately 20 HTTP requests per item
- Around 1 second per request (for simplicity)
- 4000 seconds to process all 200 items, but the scheduler kills any process running past 10 seconds due to the
stopwaitsecs
setting.
Solution
-
Increase
stopwaitsecs
: Set it to 200,000 to handle 1000 items in one command execution. The default is 10 seconds. -
Increase
numprocs
: Set it to 2 instead of 1 for the scheduler, adjusting according to your server capacity.
For more information, refer to the Laravel documentation, which highlights this issue in detail. As always, the documentation is a great resource for troubleshooting.