Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

TVHeadend not loading at boot

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
DrWiley
Posts: 9
Joined: 2019-03-03 09:57

TVHeadend not loading at boot

#1 Post by DrWiley »

Hi there,
I have trouble auto-loading the TVHeadend-service. I compiled TVHeadend from source (tvheadend: version 4.3-1768~g22eeadd11-dirty) and can run it manually without problems.

either

Code: Select all

tvheadend -f -u minimpc -g video
or

Code: Select all

/etc/init.d/tvheadend start
...both are working, as long as I don't put these commands in a startup-script.

So I tried using the tvheadend-service:

Code: Select all

systemctl enable tvheadend.service
Synchronizing state of tvheadend.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable tvheadend
Unfortunately it doesn't startup at next reboot.

Starting the service manually results in a 1 minute waiting time and the following output:

Code: Select all

systemctl start tvheadend.service
Job for tvheadend.service failed because of unavailable resources or another system error.
See "systemctl status tvheadend.service" and "journalctl -xe" for details.
Requesting the reason gives me this:

Code: Select all

systemctl status tvheadend.service
Job for tvheadend.service failed because of unavailable resources or another system error.
See "systemctl status tvheadend.service" and "journalctl -xe" for details.
root@MiniMPC:/home/minimpc/Code# systemctl status tvheadend.service
● tvheadend.service - Tvheadend - a TV streaming server and DVR
   Loaded: loaded (/lib/systemd/system/tvheadend.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: resources) since Sun 2019-03-03 11:51:04 CET; 10s ago

Mär 03 11:51:04 MiniMPC systemd[1]: Failed to start Tvheadend - a TV streaming server and DVR.
"Result: resources" ...can mean everything. There was a bug-report somewhere about this message because it's misleading users in a bunch of error-cases. TVHeadend has no forum with public access. Therefore I'm asking for help, here. I'm on Debian stretch.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: TVHeadend not loading at boot

#2 Post by Head_on_a_Stick »

Please post the output of

Code: Select all

systemctl cat tvheadend
journalctl -u tvheadend
You may need to run the `journalctl` command as root unless your normal user is a member of the systemd-journal group.

EDIT: https://tvheadend.org/projects/tvheadend/boards
Last edited by Head_on_a_Stick on 2019-03-03 10:34, edited 1 time in total.
deadbang

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#3 Post by DrWiley »

Code: Select all

systemctl cat tvheadend
# /lib/systemd/system/tvheadend.service
[Unit]
Description=Tvheadend - a TV streaming server and DVR
After=syslog.target network.target auditd.service

[Service]
EnvironmentFile=/etc/default/tvheadend
ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid $OPTIONS
PIDFile=/var/run/tvheadend.pid
Type=forking
Restart=on-failure
RestartSec=54s

# To enable watchdog functionality, uncomment these, remove Type=forking
# and compile with --enable-libsystemd_daemon
#Type=notify
#WatchdogSec=1m
#TimeoutStartSec=5m
#TimeoutStopSec=20

[Install]
WantedBy=multi-user.target

Code: Select all

journalctl -u tvheadend
has a lot of lines. I uploaded it at pastebin.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: TVHeadend not loading at boot

#4 Post by Head_on_a_Stick »

DrWiley wrote:I uploaded it at pastebin
So the relevant errors seem to be

Code: Select all

MiniMPC systemd[1]: tvheadend.service: Failed to load environment files: No such file or directory
MiniMPC systemd[1]: tvheadend.service: Failed to run 'start' task: No such file or directory
MiniMPC systemd[1]: tvheadend.service: Failed with result 'resources'.
Is /etc/default/tvheadend present and correct?

I've linked their public boards in my last post, you would probably get better help there (I don't use tvheadend).

They also appear to have some Debian packages, have you tried those?

https://tvheadend.org/projects/tvheaden ... positories

We could try an awful hack:

Code: Select all

# systemctl edit tvheadend
Then type this in:

Code: Select all

[Service]
EnvironmentFile=
ExecStart=
ExecStart=/usr/bin/tvheadend -f -u minimpc -g video
Then run

Code: Select all

# systemctl daemon-reload
# systemctl restart tvheadend
Probably a bad idea though, even if it works.
deadbang

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#5 Post by DrWiley »

The TVHeadend-server was down for a couple of days, so everything was unavailable: Wiki, Forum, Pakage-Downloads. TVheadend is not in the official debian-repos. So the only way getting it was downloading the sourcecode from github.
According to the forums: For some reason the upper border, reading "registration and login" was missing on that page, a few hours ago. I visited the page several time. No registration was possible.

So I'm very glad you help me so much.

The file /etc/default/tvheadend is not present.

I'll try your approach. I don't mind if it's dirty or not.

One more thing: When I start tvheadend manually, set computer to standby and then power-on again, tvheadend is still "running" but not usable anymore.

Edit:

It doesn't seem to work:

Code: Select all

#systemctl edit tvheadend
#systemctl daemon-reload
# systemctl restart tvheadend
Job for tvheadend.service failed because the control process exited with error code.
See "systemctl status tvheadend.service" and "journalctl -xe" for details.
# systemctl status tvheadend.service
● tvheadend.service - Tvheadend - a TV streaming server and DVR
   Loaded: loaded (/lib/systemd/system/tvheadend.service; enabled; vendor preset
  Drop-In: /etc/systemd/system/tvheadend.service.d
           └─override.conf
   Active: activating (auto-restart) (Result: exit-code) since Sun 2019-03-03 13
  Process: 1270 ExecStart=/usr/bin/tvheadend -f -u minimpc -g video (code=exited

Mär 03 13:41:59 MiniMPC systemd[1]: Failed to start Tvheadend - a TV streaming s
I'll try a reboot now.

Edit2:

No, rebooting didn't help:

Code: Select all

# systemctl status tvheadend.service
● tvheadend.service - Tvheadend - a TV streaming server and DVR
   Loaded: loaded (/lib/systemd/system/tvheadend.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/tvheadend.service.d
           └─override.conf
   Active: activating (auto-restart) (Result: exit-code) since Sun 2019-03-03 13:45:31 CET; 17s ago
  Process: 1056 ExecStart=/usr/bin/tvheadend -f -u minimpc -g video (code=exited, status=203/EXEC)
Last edited by DrWiley on 2019-03-03 11:59, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: TVHeadend not loading at boot

#6 Post by Head_on_a_Stick »

DrWiley wrote:The file /etc/default/tvheadend is not present
OK, so you should correct that instead of using my dirty hack.

Either run through the installation instructions for the source code again or try the Debian packages to which I linked earlier.
DrWiley wrote:I'll try your approach
That will create a file at /etc/systemd/system/tvheadend.service.d/override.conf — remove that file (and the tvheadend.service.d directory that contains it) to revert back to the standard behaviour.
DrWiley wrote:When I start tvheadend manually, got to standby and then power-on again, tvheadend is still "running" but not usable anymore.
What does "not usable" mean, exactly?

Verbatim error messages are always preferred over vague descriptions.
deadbang

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#7 Post by DrWiley »

Well...it means there a re no reactions: I can't watch TV anymore in kodi. I hit a channel and nothing happens. Though, when I type

Code: Select all

ps -e | grep tvheadend
I can see the program is still running.

CwF
Global Moderator
Global Moderator
Posts: 2639
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: TVHeadend not loading at boot

#8 Post by CwF »

I've recently been working on this subject and can't help with tvheadend or kodi since I haven't tried either yet.
I've decided to try it the lean unix way and to my surprise I got further faster than I thought just testing with the basic dvd-apps and w-scan which seems necessary. This category seems so disjointed that searching was leading no where, so I started probing myself and asking the computer itself and to my amazement I found those two packages alone (plus firmware/drivers and maybe something else) have all the functionality there is, but just not in a user friendly way. So, I'm listening for more fun..

A brief history, I've been using a computer TV since the 90's. A few years ago I built a qemu-kvm XP VM to do the job it was doing since ~2009, I'm watching it now. Slowly I've been moving the functions to Debian, destined for a vm. I few months ago I tested what hardware I had and nothing would work in Debian, so I got the hauppauge Quad tuner for more $ than the other 3 generic win things combined, and it's still a win thing.

So, having some experience with the sluggishness of a all-in-one app under XP, knowing what horsepower and hardware assistance it needs, I chose to do some bare-metal test first. I imaged out to SSD my standard current amd64 Buster and booted a Q67/E3 Xeon hack box, that was last Tuesday I think. I ran through many cli options and that computer yawned while streaming, recording, and displaying all 4 tuners, more than I'd ask of the vm. Today, it's clear it's going to run as a vm on my main box with no hardware assistance other than the tuner itself, I hope...

The short of it is someone with a mastery beyond mine in scripting could do it ALL without any additional packages. I'm a little in awe actually of how well it works. I'm still on a real machine with a cleanish amd64 Buster, 4.19 or 4.10 or 4.09 kernels, an i386 is on the agenda, no vm's yet since I've yet to move the card.

Note on the epg functionality, it seems to be ok on i386 and not amd64. I'll get there...but in the meantime, so I don't type out 10 pages not on point, YOU tell me if you'd like to hear more. I'd like to invite some more experienced scripters to the conversation, I'd have some questions...?

It's a white out out there today, so I'll be finishing up today. I avoided the KODI thread months ago, I don't wish to hijack this tvheadend thread, it's just I'm further along now. I could wait and hijack a VDR thread maybe?

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#9 Post by DrWiley »

I downgraded TVHeadend and used the official debian packages. Startup is working now. There was some trouble with the config-files though. TVHeadend 4.2 is crashing when reading config-files from 4.3.

Now there is only one problem left. TVHeadend is starting as the wrong user. I modified /etc/default/tvheadend and changed user "hts" to "minimpc", like this:

Code: Select all

# TVH_USER
#   if set to "" will run as root
TVH_USER="minimpc"
However, it seems to get ignored. TVHeadend is always starting as user hts. Very annoying.

CwF
Global Moderator
Global Moderator
Posts: 2639
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: TVHeadend not loading at boot

#10 Post by CwF »

Why, or what needs root?


Is your purpose a user interactive live tv console?

I was tracing through Debian to look at trying this and there are simply to many holes even sid doesn't fill.. It look like it would have to a delicate static build. So for my purposes, screw it.

Yesterday was productive though! Not enough snow, but too cold, so I'm done. Now I need to wait until I can give it some smore storage.
I did fail trying to figure out how to change the channel with a live viewer. Since I don't need live viewing, oh well. The reality of the channels.conf file wanting a copy in /etc, another in any viewer, another in a zap directory, and not all in the same format tells me this idea is not ready for prime time. So I think I'm still to scared for kodi...
What I did get working is all I need. Cron and gnutv work well together. So I will simply maintain the crontab file to cache what I watch to its own disk and be done. This is how I do it with the XP vm anyway, but it has issues with scheduling and clogs up, so my problem is solved with this simple superior debian helper vm. Now that XP is only the live viewer.
Other than not being able to change the live channel, the live viewer (mpv) in debian has the bonus of a memory cache that give pause and seek functions and I've gone up to 15 minutes back. So I may give the vm some more ram, it seems I may be configurable, and an hour of cache may help me watch 'live' tv.
So with only dvb-apps and mpv, azap creates a stream mpv can tap. Mpv can initialize it's own stream, and as said gnutv will capture to file and can be scheduled with cron. As Bare Bone Perfect as it gets!

I will say the behind the scene guts of the debian solution is superior to the XP, but then neither is as good as my old analog system. You'd think digital would be so much easier on the system, it is yet it's still not up to those early days. During some variable weather yesterday I did catch some stations breaking up so was able to compare live side by side. Launching mpv from a terminal I could see the adjustments made during viewing, that is a a-v resync, lost stream/frames, cache size, etc. Whenever I saw a 3-4 line blip in the terminal, the XP would freeze for a second or pixelate, and the mpv viewer would often remain clean and undetectable, and at worst minor pixelation of a smaller area. Maybe simply a better tuner in debian. I receive 67-72 channels and a few are dependent on the moment, so I found plenty of examples. The debian quad tuner pcie is vastly superior to the flakey 750HD pcie tuner my XP uses, the usb also on the XP is actually almost as good. That usb will be my live tuner from now on, and the quad hauppauge debian the tivo dvr thingie.

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#11 Post by DrWiley »

CwF wrote:Why, or what needs root?
I think you mean the line:

Code: Select all

#   if set to "" will run as root
This is a comment, written in /etc/default/tvheadend. I think it means tvheadend would run as root when the username was ommited.
Since the file gets ignored anyway, I found the solution in editing
/lib/systemd/system/tvheadend.service.
The line

Code: Select all

ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid $OPTIONS
needed to be changed to:

Code: Select all

ExecStart=/usr/bin/tvheadend -f -u minimpc -g video -p /var/run/tvheadend.pid $OPTIONS
...where minimpc is my chosesn username and video the group tvheadend gets executed with.

Afterwards,

Code: Select all

systemctl daemon-reload
is needed to update the service somehow.

So finally tvheadend is starting up automatically!
Still, there is some trouble left: TVheadend doesn't survive standby. After wakeup, tvheadend doesn't receive any signals anymore. I found a possible solution here.

Unfortunately it didn't work for me. Suggestions?

CwF
Global Moderator
Global Moderator
Posts: 2639
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: TVHeadend not loading at boot

#12 Post by CwF »

ok, I understand the user...root could blow up sound locally I thought...

On the suspend, no idea, not part of my formula. I did notice my setup added more than a dozen modules, so there is a lot of possibilities for any one to complain, so I punt.

I've found some yet documented work on mpv being done for channel control, so waiting...
One feed I got going was 11 channels wide and mpv could cycle any audio tracks (11) and subtitles (2) present and then continue to display a random channel of the group. In the background a terminal was going nuts reporting A-V sync errors until I cycled the audio to the matching stream and it settled down...freaky.

For local display I will continue to rely on the XP vm until debians virtio gpu drivers mature, mostly on my host side. The vfio gpu in XP has other uses too, so it stays. QXL software rendering does work but eats cpu, not what they're for...

So good luck! I'm adding space as we speak, or as I stop typing...I'm done and out!

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#13 Post by DrWiley »

CwF wrote:until I cycled the audio to the matching stream and it settled down...freaky.
yeah...freaky...that's a good point. I have absolutely no idea what you are talking about. However, I'm glad you made a supercomputer.

Regarding to my problem:
Following the instructions, I installed pm-utils, created an executable file 50_tvheadend in /etc/pm/sleep.d and put the following code inside:

Code: Select all

#!/bin/sh

case "${1}" in
  hibernate|suspend)
    /etc/init.d/tvheadend stop 
        ;;
  resume|thaw)
    /etc/init.d/tvheadend start
        ;;
  *)
    ;;
esac
This shall restart tvheadend after wakeup from standby. In addition, kernel-modules shall get reloaded on wakeup.
So I created a file:
/etc/pm/config.d/modules

Code: Select all

SUSPEND_MODULES="dvb-core saa7146 v4l2_common"
I did guess the modules to load. Maybe that's causing the problems. I also don't know if tvheadend really is getting reloaded. How do I find out?

CwF
Global Moderator
Global Moderator
Posts: 2639
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: TVHeadend not loading at boot

#14 Post by CwF »

Sorry, I have no expertise on power saving other than upgrading to a newer computer!
Maybe dmesg has some info on errors?
I typically use a terminal to step through something I'm trying to automate. Then in the terminal I can see the responses and errors. It would appear stepping through the suspend-resume sequence couldn't be done like that, so a log would be the only route. Look at increasing the error level or verbosity of some log I know nothing about...
You seem more knowledgeable than I! I'm afflicted with an excessive KISS modality, so I view suspend as not an option!

For modules look at lsmod. It will give some indication of how the modules are linked, and tell you what modules are loaded. For example on mine dvb_core has 4 modules that depend on it, the dvbdev module list 6 dependent modules, only a few in common. I see at least 35 unique modules all tied up together, all involved with the TV. Some kind of tree view would be nice.
I think it's down to figuring out the logs. Just a fun bet, the snd or media modules get hung up, without a clear log this will be a crapshoot.

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#15 Post by DrWiley »

Well, thank you anyway. The thing with lsmod, I found out already...with the same problems: I just can guess which modules belong together. I'm a big fan of the KISS-principle as well, though it's not too common in linux-world.

DrWiley
Posts: 9
Joined: 2019-03-03 09:57

Re: TVHeadend not loading at boot

#16 Post by DrWiley »

Found the solution with the help of this blog-post:

pm-utils are not working in debian stretch because of systemd. So the script has to be placed in:
/lib/systemd/system-sleep/

Furthermore, the script needs a modification: The statements are not "suspend" and "resume" anymore. They are now called "pre" and "post". So the modified script has too look like this:

/lib/systemd/system-sleep/tvheadend

Code: Select all

#!/bin/sh

case "${1}" in
  pre)
    /etc/init.d/tvheadend stop
        ;;
  post)
    /etc/init.d/tvheadend start
        ;;
  *)    
    ;;
esac
Kernel-modules don't need to get reloaded at all. For my KNC-One, running with tvheadend, the above script was all to make standby work. I made it executable with:

Code: Select all

sudo chmod ugo+x /lib/systemd/system-sleep/tvheadend
I have to say...debian's support is really poor. I needed a couple of days to find that out. It's a simple change in current debian version...and there is just no documentation or help. I also tried the german forums...same thing...just poor help.

Bye bye.

CwF
Global Moderator
Global Moderator
Posts: 2639
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: TVHeadend not loading at boot

#17 Post by CwF »

very good.

Lieta
Posts: 8
Joined: 2016-04-28 17:48

Re: TVHeadend not loading at boot

#18 Post by Lieta »

IMO adding -u -g options to /lib/systemd/system/tvheadend.service is a workaround rather than solution. Why does it ignore TVH_USER and TVH_GROUP from /etc/default/tvheadend ?

Alberto60
Posts: 8
Joined: 2021-09-07 08:27

Re: TVHeadend not loading at boot

#19 Post by Alberto60 »

I have Tvheadend running on Bullseye.
I launch it at boot with a .desktop file in ~/.config/autostart pointing to the compiled binary (haven't install it really). Work as is like years on all distros including CentOs , Fedora, LM...
Is manual launching via command line working ?

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: TVHeadend not loading at boot

#20 Post by sunrat »

Please, this thread finished 2 1/2 years ago. Resurrecting it is pointless. OP appears to have left and slammed the door on the way out.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Post Reply