Add a delay to start channels-dvr service

Need some advice. Using Ubuntu Linux server 20.04 on current machine and moving Channels dvr to a new server also running 20.04.

On the new Channels dvr, I want to install docker to run pluto and stirr containers -- easy enough.

When I install Channels dvr (not in docker) on the same machine as the docker containers, I want to delay the start of the Channels dvr service to allow the docker containers time to boot and become available. Otherwise, Channels dvr will report 0 channels for both if they are not available.

Looking at the channels.dvr-service file, I see an option for "RestartSec=10". If I change this value to a higher number (60 for example), will this method work? Is there a better method to enable a delay for Channels dvr during boot?

Interesting, I want to do this on my win10 server.

No, that's how long it waits if the software crashes and needs to be restarted.

The proper way to do this would be via dependencies, so the DVR didn't start until the dockers were up and running.

1 Like

A couple of ways to do this on Windows assuming you are running the DVR as a service.

  • Set the service start type as "Automatic (delayed)".

  • Set the start type to "Manual' then create a scheduled task to start the service however long you like after system startup.

2 Likes

The last answer here is close to what you're looking for:

Does using this in your channels-dvr.service do what you need?

[Unit]
Requires=docker.service
After=docker.service
1 Like

Been so long since I tinkered with the server I forgot I could run it as a service. Months ago I was fiddling with everything imaginable to make it work well with Win10 sleep mode but finally gave up.

I guess I just left it as a regular tray app and forgot about it. Thanks for reminding me.

Does using this in your channels-dvr.service do what you need?
[Unit]
Requires=docker.service
After=docker.service

Curious if this is a race condition. Does the docker.service dependency really mean the contained services are ready? ExecStartPre= (in the Channels DVR Service section) with a custom script to detect pluto/stirr ready (with a just-in-case timeout) seems fool-proof. A combination of the dependency above plus a fixed ExecStartPre delay would likely suffice, but a script to curl-get each endpoint would be really solid.

Adding those two entries didn't quite work. Pluto would be up and running but Strirr was not ready and the channel count was 0.

I added this to the Service section:

ExecStartPre=/bin/sleep 30

After many reboots, this looks like it's working as needed.

Thanks!