[mythtv-users] delaying mythbackend startup until a STB is available
linux at thehobsons.co.uk
Tue Feb 5 21:11:55 UTC 2019
Jerome Yuzyk <jerome at supernet.ab.ca> wrote:
> So, I was wondering if there's a way to know, at boot time, if the boot is
> happening after a power loss (not a normal shutdown), so that I could then
> delay the start of mythbackend for a couple minutes after the machine reboots
> to let the HD STB get itself together.
That's the wrong way to do it.
What you really ought to be doing - though it might not actually be possible depending on the capabilities of the STB - is to poll the STB and wait until it says it's ready. If the STB has the capabilities required, then this will work regardless of the status of stuff or the reason for a restart.
In general, this is how dependencies should be handled - the "something" that relies on "something else" being up and running should test to see if that something else is ready. That way the OS doesn't need to worry about how to determine what counts as "up" for a service/facility - it just needs to start things up.
For example, what counts as "network is up" could be different for different network using processes. For some, it may be enough that the networking stack is loaded, for others it may be that "any" interface is up and configured, for others it may be that a specific interface is up and configured, or it may be that DNS is working, or it may be that "there's a working connection to [the internet|some specific place]". Regardless of what some startup manager developers may claim, this isn't something the OS/startup manager can do in the general case - there is no way to define what (in this example) "networking is ready" means in the general case without imposing constraints that make processes fit in with the model defined rather than the startup system supporting what processes need.
Done this way, each process can apply it's own requirements, and the OS just needs to start them all at once and each one will pause until the services it depends on are ready. There is a risk of deadly embrace with circular dependencies, but there shouldn't normally be circular dependencies.
So, what does the STB support in terms of determining if it's ready. Even if the STB doesn't directly support anything, there ought to be a way to determine if it's generating valid video. Perhaps one of the experts could suggest how that might be done ?
More information about the mythtv-users