Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 690120 - media-tv/tvheadend-4.2.8 xmltv.sock and tvheadend.pid are missing when using systemd
Summary: media-tv/tvheadend-4.2.8 xmltv.sock and tvheadend.pid are missing when using ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: James Le Cuirot
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-18 05:22 UTC by James Chew
Modified: 2024-06-22 22:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
systemd service file for tvheadend (tvheadend.service,352 bytes, text/plain)
2019-08-06 06:47 UTC, James Chew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Chew 2019-07-18 05:22:09 UTC
I enabled the External: XMLTV EPG Grabber. This should create a socket at /etc/tvheadend/epggrab/xmltv.sock

When using OpenRC, the /etc/tvheadend/epggrab/xmltv.sock is created.

When using systemd, the following issues are encountered:
1. /etc/tvheadend/epggrab/xmltv.sock is NOT created.
2. /run/tvheadend/tvheadend.pid file is NOT created.

Logs as follows:
Jul 18 13:13:31 raptor systemd[1]: Started tvheadend.
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.669 [   INFO] main: Log started
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.669 [   INFO] tcp: No systemd socket: creating a new one
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.669 [   INFO] http: Starting HTTP server 0.0.0.0:9981
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.669 [   INFO] tcp: No systemd socket: creating a new one
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.669 [   INFO] htsp: Starting HTSP server 0.0.0.0:9982
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.676 [   INFO] config: loaded
Jul 18 13:13:31 raptor tvheadend[22903]: 2019-07-18 13:13:31.676 [   INFO] config: scanfile (re)initialization with path <none>
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: DVB-S - loaded 1 regions with 113 networks
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: DVB-T - loaded 44 regions with 1111 networks
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: DVB-C - loaded 17 regions with 58 networks
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: ATSC-T - loaded 2 regions with 13 networks
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: ATSC-C - loaded 1 regions with 5 networks
Jul 18 13:13:32 raptor tvheadend[22903]: 2019-07-18 13:13:32.330 [   INFO] scanfile: ISDB-T - loaded 2 regions with 1669 networks
Jul 18 13:13:34 raptor tvheadend[22903]: 2019-07-18 13:13:34.405 [   INFO] linuxdvb: adapter added /dev/dvb/adapter3
Jul 18 13:13:34 raptor tvheadend[22903]: 2019-07-18 13:13:34.405 [   INFO] linuxdvb: adapter 3 setting exclusive flag
Jul 18 13:13:36 raptor tvheadend[22903]: 2019-07-18 13:13:36.477 [   INFO] linuxdvb: adapter added /dev/dvb/adapter2
Jul 18 13:13:36 raptor tvheadend[22903]: 2019-07-18 13:13:36.477 [   INFO] linuxdvb: adapter 2 setting exclusive flag
Jul 18 13:13:38 raptor tvheadend[22903]: 2019-07-18 13:13:38.589 [   INFO] linuxdvb: adapter added /dev/dvb/adapter1
Jul 18 13:13:38 raptor tvheadend[22903]: 2019-07-18 13:13:38.589 [   INFO] linuxdvb: adapter 1 setting exclusive flag
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.725 [   INFO] linuxdvb: adapter added /dev/dvb/adapter0
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.725 [   INFO] linuxdvb: adapter 0 setting exclusive flag
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.799 [   INFO] dvr: Creating new configuration ''
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.799 [   INFO] dvr: Creating new configuration 'sdtv'
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module eit created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module uk_freesat created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module uk_freeview created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module nz_freeview created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module viasat_baltic created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module Bulsatcom_39E created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.800 [   INFO] epggrab: module psip created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.802 [   INFO] epggrab: module opentv-ausat created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.802 [   INFO] epggrab: module opentv-skyit created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.802 [   INFO] epggrab: module opentv-skynz created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.802 [   INFO] epggrab: module opentv-skyuk created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.803 [   INFO] epggrab: module pyepg created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.803 [   INFO] epggrab: module xmltv created
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.806 [  ERROR] xmltv: xmltv: failed to bind socket
Jul 18 13:13:40 raptor tvheadend[22903]: 2019-07-18 13:13:40.861 [ NOTICE] START: HTS Tvheadend version 4.2.8 started, running as PID:22903 UID:109 GID:27, CWD:/ CNF:/etc/tvheadend

#  ls -la /run/tvheadend
total 0
drwxr-xr-x  2 tvheadend video  40 Jul 18 13:13 .
drwxr-xr-x 14 root      root  460 Jul 18 13:13 ..
Comment 1 James Chew 2019-07-18 05:36:21 UTC
The /etc/tvheadend/epggrab/xmltv.sock can be created when I start tvheadend from the command line (hence the problem is when it's started as a systemd service):

# /usr/bin/tvheadend -u tvheadend -g video -c /etc/tvheadend
2019-07-18 13:29:40.160 [   INFO] main: Log started
2019-07-18 13:29:40.161 [   INFO] tcp: No systemd socket: creating a new one
2019-07-18 13:29:40.161 [   INFO] http: Starting HTTP server 0.0.0.0:9981
2019-07-18 13:29:40.161 [   INFO] tcp: No systemd socket: creating a new one
2019-07-18 13:29:40.161 [   INFO] htsp: Starting HTSP server 0.0.0.0:9982
2019-07-18 13:29:40.168 [   INFO] config: loaded
2019-07-18 13:29:40.168 [   INFO] config: scanfile (re)initialization with path <none>
2019-07-18 13:29:40.803 [   INFO] scanfile: DVB-S - loaded 1 regions with 113 networks
2019-07-18 13:29:40.803 [   INFO] scanfile: DVB-T - loaded 44 regions with 1111 networks
2019-07-18 13:29:40.803 [   INFO] scanfile: DVB-C - loaded 17 regions with 58 networks
2019-07-18 13:29:40.803 [   INFO] scanfile: ATSC-T - loaded 2 regions with 13 networks
2019-07-18 13:29:40.803 [   INFO] scanfile: ATSC-C - loaded 1 regions with 5 networks
2019-07-18 13:29:40.803 [   INFO] scanfile: ISDB-T - loaded 2 regions with 1669 networks
2019-07-18 13:29:42.761 [   INFO] linuxdvb: adapter added /dev/dvb/adapter3
2019-07-18 13:29:42.761 [   INFO] linuxdvb: adapter 3 setting exclusive flag
2019-07-18 13:29:44.833 [   INFO] linuxdvb: adapter added /dev/dvb/adapter2
2019-07-18 13:29:44.833 [   INFO] linuxdvb: adapter 2 setting exclusive flag
2019-07-18 13:29:47.009 [   INFO] linuxdvb: adapter added /dev/dvb/adapter1
2019-07-18 13:29:47.010 [   INFO] linuxdvb: adapter 1 setting exclusive flag
2019-07-18 13:29:49.187 [   INFO] linuxdvb: adapter added /dev/dvb/adapter0
2019-07-18 13:29:49.187 [   INFO] linuxdvb: adapter 0 setting exclusive flag
2019-07-18 13:29:49.253 [   INFO] dvr: Creating new configuration ''
2019-07-18 13:29:49.253 [   INFO] dvr: Creating new configuration 'sdtv'
2019-07-18 13:29:49.254 [   INFO] epggrab: module eit created
2019-07-18 13:29:49.254 [   INFO] epggrab: module uk_freesat created
2019-07-18 13:29:49.254 [   INFO] epggrab: module uk_freeview created
2019-07-18 13:29:49.254 [   INFO] epggrab: module nz_freeview created
2019-07-18 13:29:49.254 [   INFO] epggrab: module viasat_baltic created
2019-07-18 13:29:49.254 [   INFO] epggrab: module Bulsatcom_39E created
2019-07-18 13:29:49.254 [   INFO] epggrab: module psip created
2019-07-18 13:29:49.256 [   INFO] epggrab: module opentv-ausat created
2019-07-18 13:29:49.256 [   INFO] epggrab: module opentv-skyit created
2019-07-18 13:29:49.257 [   INFO] epggrab: module opentv-skynz created
2019-07-18 13:29:49.257 [   INFO] epggrab: module opentv-skyuk created
2019-07-18 13:29:49.257 [   INFO] epggrab: module pyepg created
2019-07-18 13:29:49.257 [   INFO] epggrab: module xmltv created
2019-07-18 13:29:49.259 [   INFO] xmltv: xmltv: external socket enabled
2019-07-18 13:29:49.311 [   INFO] epgdb: gzip format detected, inflating (ratio 72.3% deflated size 138)
2019-07-18 13:29:49.312 [   INFO] epgdb: parsing 191 bytes
2019-07-18 13:29:49.312 [   INFO] epgdb: loaded v2
2019-07-18 13:29:49.312 [   INFO] epgdb:   config     1
2019-07-18 13:29:49.312 [   INFO] epgdb:   brands     0
2019-07-18 13:29:49.312 [   INFO] epgdb:   seasons    0
2019-07-18 13:29:49.312 [   INFO] epgdb:   episodes   0
2019-07-18 13:29:49.312 [   INFO] epgdb:   broadcasts 0
2019-07-18 13:29:49.312 [ NOTICE] START: HTS Tvheadend version 4.2.8 started, running as PID:23153 UID:109 GID:27, CWD:/lib/systemd/system CNF:/etc/tvheadend

# ls -la /etc/tvheadend/epggrab
total 4
drwx------ 1 tvheadend video   54 Jul 18 13:33 .
drwx------ 1 tvheadend video  226 Jul 18 13:32 ..
-rw------- 1 tvheadend video 2293 Feb  1 14:16 config
drwx------ 1 tvheadend video 7616 Jul 18 13:13 otamux
drwx------ 1 tvheadend video   16 Feb  8 15:17 xmltv
srwxr-xr-x 1 tvheadend video    0 Jul 18 13:29 xmltv.sock
Comment 2 James Le Cuirot gentoo-dev 2019-08-04 11:43:37 UTC
I don't use systemd on Gentoo and I only run tvheadend on one system that isn't capable of running systemd at all. I also don't use XMLTV. I'd therefore be very grateful if you could suggest a fix that works for you.
Comment 3 James Le Cuirot gentoo-dev 2019-08-04 11:45:51 UTC
Actually if I had to guess, it's the RestrictAddressFamilies entry in the unit file. It should include AF_UNIX.
Comment 4 James Chew 2019-08-06 06:47:01 UTC
Created attachment 585844 [details]
systemd service file for tvheadend
Comment 5 James Chew 2019-08-06 06:48:45 UTC
I tried a few options, but only managed to get the xmltv.sock file when I recreated the tvheadend.service file as attached.
Comment 6 James Le Cuirot gentoo-dev 2019-08-10 09:03:57 UTC
That's completely different to what we have now, even right down to the Type. Can you start with what we have and remove the lines one at a time? I would start with RestrictAddressFamilies.
Comment 7 James Chew 2019-08-10 12:56:07 UTC
(In reply to James Le Cuirot from comment #6)
> That's completely different to what we have now, even right down to the
> Type. Can you start with what we have and remove the lines one at a time? I
> would start with RestrictAddressFamilies.

Yes I started with that; deleted all the lines that I felt would have made a difference, specifically:
DevicePolicy=closed
DeviceAllow=char-DVB rw
DeviceAllow=char-drm rw
RestrictAddressFamilies=AF_INET AF_INET6
ProtectSystem=yes
ProtectHome=yes
NoNewPrivileges=yes

And yet, that did not solve the problem. I.e. after starting tvheadend
/etc/tvheadend/epggrab/xmltv.sock is missing
/run/tvheadend/tvheadend.pid file is missing

Thus, I ended up taking the developer's systemd service file, modified from there and it works.
Comment 8 Dominic Pearman 2024-06-22 15:42:20 UTC
(In reply to James Le Cuirot from comment #3)
> Actually if I had to guess, it's the RestrictAddressFamilies entry in the
> unit file. It should include AF_UNIX.

Hi,

I ran into this issue setting up the external XMLTV EPG grabber for TVHeadend 4.3_p20240322 with systemd. Attempting to enable the EPG Grabber module 'External: XMLTV' via the web interface caused TVHeadend to crash with a core dump with the packaged systemd service. Adding AF_UNIX to the RestrictAddressFamilies entry as you suggest fixes it and allows TVHeadend to create a socket file at /etc/tvheadend/epggrab/xmltv.sock.

The file /run/tvheadend/tvheadend.pid file is not created. This has yet to cause any problems for my setup however, so I assume it is not necessary.

It seems as though your guess is correct :)
Comment 9 Larry the Git Cow gentoo-dev 2024-06-22 22:00:51 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ebcc4c065037a790df488d1a7874d9b8f9701b9

commit 2ebcc4c065037a790df488d1a7874d9b8f9701b9
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2024-06-22 21:57:41 +0000
Commit:     James Le Cuirot <chewi@gentoo.org>
CommitDate: 2024-06-22 22:00:24 +0000

    media-tv/tvheadend: Bump snapshot to 20240618, fix systemd service
    
    UNIX socket permission is needed for xmltv integration.
    
    The PID file is not created or used because the systemd service is
    "simple" with tvheadend running in the foreground.
    
    Closes: https://bugs.gentoo.org/690120
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>

 media-tv/tvheadend/Manifest                                         | 2 +-
 media-tv/tvheadend/files/tvheadend.service                          | 5 ++---
 ...vheadend-4.3_p20240322.ebuild => tvheadend-4.3_p20240618.ebuild} | 6 ++----
 media-tv/tvheadend/tvheadend-9999.ebuild                            | 1 -
 4 files changed, 5 insertions(+), 9 deletions(-)
Comment 10 James Le Cuirot gentoo-dev 2024-06-22 22:09:58 UTC
Big thanks for testing that. It's great to finally close this out.