[mythtv-users] Config backend for multiple frontends question

Stephen Worthington stephen_agent at jsw.gen.nz
Sun Jul 23 00:01:50 UTC 2017


On Sat, 22 Jul 2017 13:46:28 -0400, you wrote:

>On 07/21/2017 09:24 PM, Stephen Worthington wrote:
>> On Fri, 21 Jul 2017 17:27:09 -0400, you wrote:
>
>> You also need to ensure that mythbackend does not start before the
>> external network interfaces are up.  If it does, it fails to bind the
>> external IP addresses and instead falls back to using localhost, and
>> the frontends can not connect to it.  So the same fix is needed as
>> when you are using network tuners.
>
>On Fedora with systemd, I used to have a 'sleep 10' as the first line in 
>a pre-start.sh script fired up before the call to mythbackend. The 
>pre-start.sh script also makes sure that the correct folders and links 
>are ready too.
>Changing the [Unit] section of the mythbackend.service file to add:
>
>After=network.target mariadb.service NetworkManager-wait-online.service
>
>fixes that problem... AIUI these lines force a wait until things are 
>stable, before actually starting the service.
>
>Geoff

A simple sleep like that is normally unreliable as sometimes things
just take longer for some reason (eg fsck needed on a partition).  It
is much better to get it to wait until the networking is actually up,
which the NetworkManager-wait-online.service does.  However, that
service is not enabled by default on some systems (eg Ubuntu), so you
also need to do:

systemctl status NetworkManager-wait-online.service

to check if it is enabled and then if it is not:

systemctl enable NetworkManager-wait-online.service
systemctl start NetworkManager-wait-online.service

Also, you should never modify the .service files that are installed
from the packages, as they will be overwritten whenever the package is
updated.  Systemd has a prescribed method of overriding settings in an
existing .service file from an override file, and that is how any
changes need to be implemented.  So in Ubuntu, you create a new
directory with a new file in it such as
/etc/systemd/system/mythtv-backend.d/mythtv-backend.conf, and put the
changes in there.  This is what I recommend (from a root prompt or use
sudo):

cd /etc/systemd/system
mkdir mythtv-backend.service.d
chown root:root mythtv-backend.service.d
chmod a=rx,u+w mythtv-backend.service.d
cd mythtv-backend.service.d
touch mythtv-backend-override.conf
chown root:root mythtv-backend-override.conf
chmod a=rw mythtv-backend-override.conf

Then edit the mythtv-backend-override.conf file to contain this:

[Unit]
Wants=NetworkManager-wait-online.service
After=NetworkManager-wait-online.service

and then reboot.

In Ubuntu, the wait for network.target and mysql.target are already in
the /lib/systemd/system/mythtv-backend.service file, so they do not
need to be in the override file:

root at lith:/lib/systemd/system# cat mythtv-backend.service
[Unit]
Description=MythTV Backend
Documentation=https://www.mythtv.org/wiki/Mythbackend
After=mysql.service network.target

[Service]
User=mythtv
EnvironmentFile=-/etc/mythtv/additional.args
ExecStart=/usr/bin/mythbackend --quiet --syslog local7
$ADDITIONAL_ARGS
StartLimitBurst=10
StartLimitInterval=10m
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

However, on server systems, NetworkManager is normally not installed,
so you have to use something else to know when the external network
interfaces are up.  That may require installing and/or enabling the
pingnetwork.service and using that to ping a target address to know
that networking is fully up.


More information about the mythtv-users mailing list