Page 1 of 1

Delay backend startup for device detection with systemd

Posted: Thu Nov 22, 2018 4:43 pm
by dantengwen
fter upgrading my (0.28) backend to Ubuntu 16.04 it would not reliably use all tuners. The backend service was starting before udev had detected all USB devices and created symlinks for them.

Creating this systemd configuration file will delay the start of the backend service until udev has settled:

# file /etc/systemd/system/mythtv-backend.service.d/mythtv-backend.conf
# Delay mythtv backend start until all tuners have been detected

[Unit]
After=systemd-udev-settle
EDIT: Add errors from mythbackend.log


Jan 4 10:15:19 tv mythbackend: mythbackend[1385]: W CoreContext recorders/dvbchannel.cpp:245 (Open) DVBChan[1](/dev/dvb/adapter_pctv/frontend0): Opening DVB frontend device failed.#012#011#011#011eno: No such file or directory (2)
Jan 4 10:15:19 tv mythbackend: mythbackend[1385]: E CoreContext recorders/dvbchannel.cpp:250 (Open) DVBChan[1](/dev/dvb/adapter_pctv/frontend0): Failed to open DVB frontend device due to fatal error or too many attempts.
Jan 4 10:15:19 tv mythbackend: mythbackend[1385]: E CoreContext recorders/channelbase.cpp:871 (CreateChannel) ChannelBase: CreateChannel() Error: Failed to open device /dev/dvb/adapter_pctv/frontend0
Jan 4 10:15:19 tv mythbackend: mythbackend[1385]: E CoreContext main_helpers.cpp:202 (setupTVs) Problem with capture cards. Card 1 failed init

Re: Delay backend startup for device detection with systemd

Posted: Thu Nov 22, 2018 5:31 pm
by bill6502
systemctl cat systemd-udev-settle has some interesting comments in it. I've
never used it with the backend service. Here's my unit section:

Code: Select all

[Unit]
...
Wants=dev-dvb-adapter0-frontend0.device dev-dvb-adapter1-frontend0.device
After=dev-dvb-adapter0-frontend0.device dev-dvb-adapter1-frontend0.device
And from /etc/udev/rules.d/mythtv.conf

Code: Select all

SUBSYSTEM=="dvb", \
    KERNEL=="dvb?.frontend0", \
    ATTRS{subsystem_vendor}=="0x0070", \
    ATTRS{subsystem_device}=="0x8851", \
    SYMLINK+="dvb/hvr-2200-$minor", \
    TAG+="systemd"
See: https://www.mythtv.org/wiki/Systemd_myt ... nitialized

I've also never tried it with USB devices.