Does runit support to delay to first start

340 Views Asked by At

I met a problem about the runit service bootstrap. The service will setup and curl an external service endpoint to get its data. It will restart over and over again and keep sending requests until the data is ready for the external service.

So I thought there is remediation to reduce the requests which delay the runit service to run the script for the first time. But I could not find any way to delay the runit service. Does runit support delay its service to the first start? Or the solution has any improvement?

BTW, the service will setup with system boot.

1

There are 1 best solutions below

0
Gordon Seidoh Worley On

You might try changing the runlevel of runit so that it doesn't start too soon, but that depends on the dependent process running first. A better solution, described in the documentation, is to use the fact that runit will try to start a service again if it dies, so you can do the following in your run script:

sv start dependent_service || exit 1
# my service code

This will ensure that dependent_service is started first.