systemd configuration

Added by neik neik about 10 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 ###


ExecStart=/usr/local/bin/tvheadend-3.2.18/build.linux/tvheadend -f -u USERNAME -g GROUPNAME


  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

Replies (6)

RE: systemd configuration - Added by Peter Vágner about 10 years ago

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...

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


for me this works fine:

# Whats oscam?
# Wants: would like to have, After: start after, Requires: needs

# tvheadend nees root priv to create pid file and switch to user hts.
ExecStart=/usr/bin/tvheadend -f -p /run/ -u hts -g video
ExecStop=/usr/bin/rm /run/



Got most of it from:

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

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/
Description=Restart TVHeadend on suspend/hibernate/hybrid

ExecStart=/bin/systemctl start tvheadend


$ cat /etc/systemd/system/
Description=Stop TVHeadend on suspend/hibernate/hybrid

ExecStart=/bin/systemctl stop tvheadend


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 8 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/ is as follows:


case "$1" in
service tvheadend stop
sleep 3
modprobe -v -r smipcie si2168 m88ds3103
modprobe -v smipcie
sleep 1
service tvheadend start

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 over 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 6 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?