Project

General

Profile

systemd configuration

Added by neik neik over 9 years ago

Hey together,

I installed a tvheadend on fedora 18 under xbmc and everything is working well. there is one single problem. I can't get tvheadend start probably automatically after boot. The systemd starts the tvheadend and then the deamon crashs without any detailed information. I searched for systemd examples and tried something with tvheadend.service examples, but I can't get it work.

My tvheadend cconfigration file:

  1. begin file ###

[Unit]
Description=tvheadend
Wants=network.target

[Service]
User=USERNAME
Type=forking
ExecStart=/usr/local/bin/tvheadend-3.2.18/build.linux/tvheadend -f -u USERNAME -g GROUPNAME

[Install]
WantedBy=multi-user.target

  1. end file ###

the file ist stored under /etc/systemd/system/tvheadend.service

one second interesting point is that I am able to start the deamon with this command with this user without any problems.

any ideas?

best regards
neik


Replies (6)

RE: systemd configuration - Added by Peter Vágner over 9 years ago

Hello,
I have tried tvheadend on arch linux. It is started from systemd and I have not experienced issues like this.
On arch the package adds an hts user and the daemon is running with these three parameters
-c -u hts -g video
The only difference is the -f parameter. Otherwise can tvheadend access dvb devices?
Here is the aur entry if you would like to have a look...
https://aur.archlinux.org/packages/tvheadend/

RE: systemd configuration - Added by JP T about 7 years ago

Hi,

for me this works fine:

[Unit]
Description=tvheadend
Wants=network.target
After=network.target
# Whats oscam?
#Wants=oscam.service
#After=oscam.service
# Wants: would like to have, After: start after, Requires: needs

[Service]
User=root
# tvheadend nees root priv to create pid file and switch to user hts.
#Group=
Type=forking
PIDFile=/run/tvheadend.pid
ExecStart=/usr/bin/tvheadend -f -p /run/tvheadend.pid -u hts -g video
ExecStop=/usr/bin/rm /run/tvheadend.pid
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

[Service]
Type=forking

Got most of it from:
https://github.com/tvheadend/tvheadend-packaging/blob/master/systemd/tvheadend.service

RE: systemd configuration - Added by JP T almost 7 years ago

Well...
Manually starting works: "systemctrl start tvheadend"
But automatic start does not work yet. Tried "systemctrl enable tvheadend", let's see if this helps.

Suspend scripts:

$ cat /etc/systemd/system/suspend.target.wants/tvheadend-resume.service
[Unit]
Description=Restart TVHeadend on suspend/hibernate/hybrid
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=simple
ExecStart=/bin/systemctl start tvheadend

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

$ cat /etc/systemd/system/suspend.target.wants/tvheadend-suspend.service
[Unit]
Description=Stop TVHeadend on suspend/hibernate/hybrid
Before=sleep.target

[Service]
Type=simple
ExecStart=/bin/systemctl stop tvheadend

[Install]
WantedBy=sleep.target

Stop/Start works now, but it cannot record. No Stream. /dev/dvb/adapter0 exists... maybe I have to reload the modules. How do I do that in systemd?

Does anybody understand why this is working? What exactly is going on?

RE: systemd configuration - Added by c128 m almost 7 years ago

Personally didn't realise that systemd supported sleep/wake stuff, but I guess that does make sense.

Not an answer to your systemd specific question, but I'm running tvheadend on Ubuntu 15.04 with systemd (albeit wrapping the init.d and using service) and just use my own version of the sleep/wake script that's listed in the forums. This does require an install of pm-utils and, yeah, you do have to unload/load the modules. My current script, for 3xDVBSky T9580s, /etc/pm/sleep.d/99_htpc.sh is as follows:

#!/bin/bash

case "$1" in
suspend|hibernate)
service tvheadend stop
sleep 3
modprobe -v -r smipcie si2168 m88ds3103
;;
resume|thaw)
modprobe -v smipcie
sleep 1
service tvheadend start
;;
esac

I would guess similar works using systemctl instead of service, but I'd be interested too how you achieve the same module-business with systemd "natively".

As a (general) aside - hope you don't have TBS adapters. It seems some folk have these working with sleep/wake, but I found my ones a world of pain with the OS drivers - could never get them working properly on resume (amongst having other issues). Gave up in the end and replaced them - the DVBSky cards have been great.

RE: systemd configuration - Added by JP T almost 6 years ago

Because of this problem and some more, I did a fresh install of Kubuntu 16.04.
Waking up Tvheadend after standby works out of the box now.
What doesn't work is waking up from standby for scheduled recordings. I am working on it.

RE: systemd configuration - Added by Robin Mitra over 5 years ago

My suggestion is:
- Tvheadend maintains a systemd.timer (with the wake flag enabled)
- this timer gets updated either everytime the internal scheduled tasks change (i.e. the timer contains the date/time of the next task tvh needs perform, that copuld be recording or scan, or whatever...)
or in the tvh suspend task itself.
- whenever the timer is updated, don't forget to issue a systemctl daemon-reload
- and yes that works also in the tvh suspend unit

This way of way of setting a wake time when the system suspends works. Unfortunately, the drivers don't really like suspend resume, and even removing them on suspend, reloading them on resume doesn't seem to work properly. The dependencies are a mess (ddbridge, in my case).

Also, IMHO tvh should prevent sleep when it has do to something and reallow when idle (can be done via d-bus/logind).
what remains is who is responsible for putting the system to sleep, powertop?

    (1-6/6)