You can run background tasks running in parallel of your application. They will be restarted automatically on error. Those are especially useful for environments where you can’t have long-running processes such as PHP, Ruby or Python.
The workers run in the same environment as your application. They are launched as services by systemd, in the application’s directory.
All you need to do is add one (or several) environment variables as such:
By default, workers will be restarted if they exit with an error code. You can customise this behavior by setting the
CC_WORKER_RESTART to one of
on-failure (the default) or
You can define a delay to restart your worker with the environement variable
CC_WORKER_RESTART_DELAY, the value is in seconds with a default value of
1. It will apply to all registered workers.
CC_WORKER_RESTART_DELAY value is too low and the restart policy is set to
always, your worker might hit the restart burst limit, which may prevent your worker from being correctly restarted.
If you want to have a restart delay less than 1 second and expect your script to restart multiple times in a very short time, please let us know on our support.
Did this documentation help you ?