<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 1, 2019, 10:42 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 1 Jul 2019 09:35:50 -0700, you wrote:<br>
<br>
>On Sun, Jun 30, 2019, 10:14 PM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz" target="_blank" rel="noreferrer">stephen_agent@jsw.gen.nz</a>><br>
>wrote:<br>
><br>
>> On Sun, 30 Jun 2019 17:28:07 -0700, you wrote:<br>
>><br>
>> >Ok this is strange.  I added a couple channels on schedules direct, ran<br>
>> >mythfilldatabase, and restarted the Myth machine. Now the STB channels are<br>
>> >there on watch live TV.  This makes no sense. It has been restarted<br>
>> several<br>
>> >times since I had this problem, and mythfilldatabase runs daily (I think).<br>
>> >So go figure.<br>
>><br>
>> Just checking, do you have the systemd fix that makes mythbackend only<br>
>> start when the network is up and it can access the networked tuners?<br>
>> ____________________________________<br>
>><br>
><br>
>If it's something I had to install separately, no.<br>
<br>
In that case, every time you boot, you will be suffering from a race<br>
condition.  Mythbackend tests all the tuners at startup, and if it can<br>
not get a good response from a tuner when it tests it, that tuner is<br>
marked as bad and is never used until mythbackend is restarted.<br>
Systemd is able to start mythbackend faster and faster with each new<br>
version of systemd and Ubuntu.  This is the default systemd unit file<br>
for mythbackend:<br>
<br>
root@mypvr:/lib/systemd/system# cat mythtv-backend.service<br>
[Unit]<br>
Description=MythTV Backend<br>
Documentation=<a href="https://www.mythtv.org/wiki/Mythbackend" rel="noreferrer noreferrer" target="_blank">https://www.mythtv.org/wiki/Mythbackend</a><br>
After=mysql.service network.target<br>
<br>
[Service]<br>
User=mythtv<br>
EnvironmentFile=-/etc/mythtv/additional.args<br>
ExecStart=/usr/bin/mythbackend --quiet --syslog local7<br>
$ADDITIONAL_ARGS<br>
StartLimitBurst=10<br>
StartLimitInterval=10m<br>
Restart=on-failure<br>
RestartSec=1<br>
<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
It starts mythbackend as soon as mysql is started, and<br>
"network.target" is reached.  Unfortunately, "network.target" happens<br>
when any network interface is available, so as soon as the localhost<br>
(127.0.0.1) interface is available, "network.target" happens and<br>
mythbackend is started.  But at that time, the Ethernet interface(s)<br>
and all the other network interface(s) that you may have are still<br>
starting up.  By the time mythbackend tries to test the first network<br>
tuner, the Ethernet interfaces are not up yet, so mythbackend marks<br>
that tuner bad and goes on to try the next tuner.  Since testing a<br>
tuner takes a while, at some point in the process of testing all the<br>
tuners, the Ethernet interface may come up, and after that, the<br>
testing of the network tuners succeeds.<br>
<br>
This was a problem in 16.04 with most people still booting from hard<br>
disk.  Now that we are running 18.04 and above, and booting from SSD,<br>
mythbackend it getting started much earlier, and the chance that the<br>
network tuners will fail testing is increased significantly.<br>
<br>
Whether this is your actual problem, I am not sure, but it is a good<br>
candidate and something you (and anyone who uses network tuners)<br>
really need to fix anyway.<br>
<br>
The fix is a bit complicated - you have to make a systemd unit that<br>
tests for the Ethernet interface actually being up and able to pass<br>
traffic, and then have mythbackend wait on that unit before it is<br>
started.  The tools to do this are on my web server.  If you are not<br>
running a server version of Ubuntu and have not disabled<br>
NetworkManager, run the following commands to set it all up.  Watch<br>
out for line wrapping - my email client does that with longer lines<br>
such as the wget commands, so the wget and the URL after it should be<br>
on one line.<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 noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/wait-until-pingable.py</a><br>
chmod u=rwx,g=r,o=r wait-until-pingable.py<br>
systemctl enable NetworkManager-wait-online.service<br>
systemctl start NetworkManager-wait-online.service<br>
cd /etc/systemd/system<br>
mkdir mythtv-backend.service.d<br>
chmod u=rwx,g=rx,o=rx mythtv-backend.service.d<br>
cd mythtv-backend.service.d<br>
wget<br>
<a href="http://www.jsw.gen.nz/mythtv/mythtv-backend-wait-until-pingable.conf" rel="noreferrer noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/mythtv-backend-wait-until-pingable.conf</a><br>
chmod u=rw,g=r,o=r mythtv-backend-wait-until-pingable.conf<br>
cd ..<br>
wget <a href="http://www.jsw.gen.nz/mythtv/local-network-pingable.service" rel="noreferrer noreferrer" target="_blank">http://www.jsw.gen.nz/mythtv/local-network-pingable.service</a><br>
chmod u=rw,g=r,o=r local-network-pingable.service<br>
<br>
Here you will need to change the text in<br>
local-network-pingable.service where it says "<a href="http://switch.jsw.gen.nz" rel="noreferrer noreferrer" target="_blank">switch.jsw.gen.nz</a>" and<br>
replace that with the IP address or DNS name of your first network<br>
tuner (if the tuner is pingable), or otherwise something on your<br>
network such as your switch or router that is normally pingable when<br>
your MythTV box is booting.<br>
<br>
Use nano or your favourite editor:<br>
<br>
nano local-network-pingable.service<br>
<br>
Then save the change and exit from nano or your editor and do these<br>
commands:<br>
<br>
systemctl enable local-network-pingable.service<br>
systemctl start local-network-pingable.service<br>
systemctl status local-network-pingable.service<br>
<br>
The systemctl status command should show that the<br>
local-network-pingable.service has started and the ping worked.  If<br>
not, fix that before proceeding.  Then do these commands:<br>
<br>
systemctl daemon-reload<br>
exit<br>
<br>
After that, on boot mythbackend will wait for either the ping to work,<br>
or the 30 second timeout specified in the<br>
local-network-pingable.service file.  If you want to change that<br>
timeout, it is the "30" after the ping address.<br>
<br>
Since I just typed out all of the above commands, it is possible I may<br>
have a typo somewhere, so please let me know if I have.<br>
_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org" target="_blank" rel="noreferrer">mythtv-users@mythtv.org</a><br>
<a href="http://lists.mythtv.org/mailman/listinfo/mythtv-users" rel="noreferrer noreferrer" target="_blank">http://lists.mythtv.org/mailman/listinfo/mythtv-users</a><br>
<a href="http://wiki.mythtv.org/Mailing_List_etiquette" rel="noreferrer noreferrer" target="_blank">http://wiki.mythtv.org/Mailing_List_etiquette</a><br>
MythTV Forums: <a href="https://forum.mythtv.org" rel="noreferrer noreferrer" target="_blank">https://forum.mythtv.org</a></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Ok thanks for the how-to.  I will go through the procedure if I continue to have problems, but everything seems to be working fine right now.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
</blockquote></div></div></div>