<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sat, Feb 15, 2025 at 6:08 AM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, 15 Feb 2025 00:28:45 -0800, you wrote:<br>
<br>
>Anyone else having issues with the startup order on Ubuntu 24.04 LTS and<br>
>mythtv v34, mythtv-backend starts up, but the hdhomerun tuners can't be<br>
>found and some other weird errors in the log. However, doing a "systemctl<br>
>restart mythtv-backend.service" after the system fully boots up, things are<br>
>fine. After I made the mythtv-backend start up a bit later like after<br>
>apache2, it seems to work fine. I don't quite understand what are the<br>
>missing dependencies in the startup sequence.<br>
><br>
>Original After= lines...<br>
># systemctl show mythtv-backend.service |grep ^After<br>
>After=sysinit.target system.slice mariadb.service basic.target<br>
>network.target systemd-journald.socket<br>
><br>
>I am making it depend on apache2 to make it startup later..<br>
># systemctl edit mythtv-backend.service<br>
>Added:<br>
>[Unit]<br>
>After=apache2.service<br>
><br>
>Generated:<br>
>/etc/systemd/system/mythtv-backend.service.d/override.conf<br>
>[Unit]<br>
>After=apache2.service<br>
><br>
>Now<br>
># systemctl show mythtv-backend.service |grep ^After<br>
>After=sysinit.target network.target mariadb.service basic.target<br>
>apache2.service systemd-journald.socket system.slice<br>
><br>
>Startup sequence is fine now.<br>
<br>
This is a really old problem now, with lots of solutions on this list<br>
and elsewhere. Mythbackend does not have the good network code found<br>
in some other programs such as mysql where it will detect changes on<br>
the network interfaces and react to them. It requires that the<br>
network be actually up and working when it starts, otherwise it will<br>
not set up its network connections, and consequently will not see<br>
network tuners or allow remote mythfrontend connections. Even if the<br>
network comes up later, it will never re-check to see if it is now<br>
available.<br>
<br>
The standard mythtv-backend.service units in various distros normally<br>
only wait for "network.target" before starting mythbackend. But<br>
"network.target" happens when the first network interface becomes<br>
available. So when localhost comes up very early (as it is purely a<br>
software interface and does not need to wait for any hardware to be<br>
initialised and working), network.target comes up and mythbackend gets<br>
started. But it then only sees the localhost interface and can not<br>
connect to the local network. So to prevent this problem, you need to<br>
get the mythtv-backend.service unit to wait until the specific network<br>
connection(s) it needs are actually working (not just the interface<br>
available, but able to connect to HDHR tuners, for example).<br>
<br>
What you have done by making mythbackend wait for apache2 to be up and<br>
running may be OK most of the time, but I suspect that apache2 is one<br>
of those programs that will monitor and react to network interface<br>
changes, in which case it is still possible that the network will at<br>
times not be working well enough for mythbackend when apache2 is<br>
running. So I would not recommend doing what you are doing. Instead,<br>
I always recommend a fix that will definitely start mythbackend only<br>
after the required network interface(s) are not only up but are<br>
demonstrably passing packets.<br>
<br>
The way I do it is to use a "local-network-pingable.service" that I<br>
wrote that pings a device on the local network and does not come up<br>
until it gets a ping reply. In my case, I ping my Ethernet switch.<br>
Not all Ethernet switches reply to pings, but in your case you have<br>
HDHRs which should reply to pings.<br>
<br>
root@mypvr:/etc/systemd/system# systemctl cat<br>
local-network-pingable.service<br>
# /etc/systemd/system/local-network-pingable.service<br>
[Unit]<br>
Description=Wait for the local network to be pingable<br>
After=network.target<br>
<br>
[Service]<br>
Type=simple<br>
# Do not use DNS names here, as the starting of bind9 is dependent on<br>
local-network-pingable.service,<br>
# so DNS lookup is not available until after<br>
local-network-pingable.service succeeds.<br>
ExecStartPre=/bin/bash -c "/usr/local/bin/wait-until-pingable.py<br>
10.0.2.245 30"<br>
ExecStart=/bin/true<br>
<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
Note that the comments about DNS names are unlikely to apply to you -<br>
I run my secondary DNS server on the same PC as mythbackend.<br>
<br>
The wait-until-pingable.py program is one I also wrote for myself. It<br>
is available for download from my web server:<br>
<br>
<a href="http://www.jsw.gen.nz/mythtv/wait-until-pingable.py" rel="noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/wait-until-pingable.py</a><br>
<br>
as is a generic version of the local-network-pingable.service file:<br>
<br>
<a href="http://www.jsw.gen.nz/mythtv/local-network-pingable.service" rel="noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/local-network-pingable.service</a><br>
<br>
To set this up run this:<br>
<br>
sudo su<br>
cd /usr/local/bin<br>
wget <a href="http://www.jsw.gen.nz/mythtv/wait-until-pingable.py" rel="noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/wait-until-pingable.py</a><br>
chown root:root wait-until-pingable.py<br>
chmod u=rwx,g=rx,o=rx wait-until-pingable.py<br>
cd /etc/systemd/system<br>
wget <a href="http://www.jsw.gen.nz/mythtv/local-network-pingable.service" rel="noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/local-network-pingable.service</a><br>
chown root:root local-network-pingable.service<br>
chmod u=rw,g=r,o=r local-network-pingable.service<br>
<br>
Here edit the local-network-pingable.service file and put in the DNS<br>
name or IP address of one of your HDHR tuners or of some other device<br>
that will be pingable on your local network. Then do:<br>
<br>
systemctl edit mythtv-backend<br>
<br>
Here edit the mythtv-backend override file. Delete the existing<br>
"After=apache2.service" line and add these two lines:<br>
<br>
Wants=local-network-pingable.service<br>
After=local-network-pingable.service<br>
<br>
Save and exit the editor. Then run:<br>
<br>
systemctl daemon-reload<br>
systemctl enable --now local-network-pingable.service<br>
exit<br>
<br>
Make sure that local-network-pingable.service is working by doing:<br>
<br>
sudo systemctl status local-network-pingable.service<br>
<br>
Then reboot to check that it is all working properly.</blockquote><div><br></div><div>I use 2 different solutions depending on the tuner. On my production backend with a PCIe tuner card I use Stephen's solution mentioned above.</div><div><br></div><div>On my test systems with HDHomerun tuners I use the one I posted on the Mythtv forum.</div><div><a href="https://forum.mythtv.org/viewtopic.php?f=29&t=5846">https://forum.mythtv.org/viewtopic.php?f=29&t=5846</a></div><div><br></div><div>JIm A</div><div> <br></div></div></div>