[mythtv-users] systemd foo

Stephen Worthington stephen_agent at jsw.gen.nz
Thu Jan 11 06:30:37 UTC 2024

On Thu, 11 Jan 2024 13:09:36 +0800, you wrote:

>> On Jan 10, 2024, at 11:31, Stephen Worthington <stephen_agent at jsw.gen.nz> wrote:
>> On Wed, 10 Jan 2024 06:13:25 +0800, you wrote:
>>> Multiple Wants on same line and enable again got it working. (many failed tries)
>>> [Unit]
>>> Description=MythTV backend service
>>> Wants=store.mount dev-dvb-adapter0.mount dev-dvb-adapter3.mount
>>> Requires=mysql.service
>>> After=store.mount dev-dvb-adapter3.mount dev-dvb-adapter0.mount mysql.service
>>> [Service]
>>> Type=simple
>>> EnvironmentFile=/etc/sysconfig/mythbackend.env
>>> User=jam
>>> Group=video
>>> ExecStart=/usr/local/bin/mythbackend --logpath /var/log/mythtv $MYTHBACKEND_OPTIONS
>>> [Install]
>>> WantedBy=multi-user.target
>>> James
>> dev-dvb-adapter<x>.mount is wrong.  It should be
>> dev-dvb-adapter<x>-frontend0.device.  To make this work, you need to
>> add these udev rules:
>> root at mypvr:/etc/udev/rules.d# cat 99-tuner.rules
>> #
>> # Create systemd device units for capture devices
>> #
>> SUBSYSTEM=="video4linux", TAG+="systemd"
>> SUBSYSTEM=="dvb", TAG+="systemd"
>> SUBSYSTEM=="firewire", TAG+="systemd"
>> The "dvb" one is the one you need, but it is best to add them all just
>> in case.
>> The naming is done the same way as the .mount names:
>> Device path: /dev/dvb/adapter0/frontend0
>> Becomes:     dev-dvb-adapter0-frontend0.device
>> Having those device names wrong will likely be causing a long timeout
>> (60 seconds?) before mythbackend is started.
>> Make sure you always remember to do:
>> sudo systemctl daemon-reload
>> every time you make any changes to the systemd files.  Otherwise the
>> changes will not be seen.
>The deeper I wade in to an area I don’t understand 

>I have this
>Description=MythTV backend service
>Wants=store.mount dev-dvb-adapter0.device dev-dvb-adapter3.device
>After=store.mount dev-dvb-adapter3.device dev-dvb-adapter0.device mysql.service
>ExecStart=/usr/local/bin/mythbackend --logpath /var/log/mythtv $MYTHBACKEND_OPTIONS
>Initially I forgot to update Wants from .mount to .device
>mythbackend started in “off line” mode. Restart worked ok.
>mythbackend starts normally after a [guess] 1 minute timeout.
>I could just timeout before starting, already subtle timing changes made the service that ‘worked’ for years fail, so I’m keen to not use arbituary delays.
>How do I tell if the udev items for systemd are being created?
>This hardware, GMK K1, does not generate an event for usb devices at boot time, only for plug events. I can see the device files (adaper[1234]). Any reason to not wait for .mount on those instead of .device ?

The .mount units are only created for mountpoints.  There will never
be a dev-dvb-adapter0.mount created.  The .device units are created by
udev rules.  There a lots of default udev rules that do this for
various devices, but you have to manually create the specific rule for
dvb devices as there is not a default rule for that.

A 60 second timeout usually means that there is an unfulfilled After
requirement.  So the first step in debugging that is to check all the
After units to see if they exist and what their state is:

sudo su
systemctl status store.mount
systemctl status dev-dvb-adapter3.device
systemctl status dev-dvb-adapter0.device
systemctl status mysql.service

I think you will find that the dev-dvb-adapter3.device and
dev-dvb-adapter0.device units do not exist.  As per my previous reply,
the correct units should be:


Note the extra -frontend0 part.  The /dev/dvb and /dev/dvb/adapter<x>
paths end in directories, not device files, so they do not trigger the
"dvb" udev rule.  Only device files such as
/dev/dvb/adapter0/frontend0 will trigger the udev rule that creates a
matching dev-dvb-adapter0-frontend0.device unit.

More information about the mythtv-users mailing list