Backend requires restart to recognize hdhomerun tuners

For discussion of topics specific to MythTV on linux
User avatar
bill6502
Developer
Posts: 1377
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by bill6502 » Sun May 08, 2016 3:31 pm

Interesting problem. My browser (Vivaldi) doesn't append 4 leading spaces
when I mouse over and copy, or even use the "SELECT ALL" feature.

The kernel looks at the 1st 16 bits, so it's not seeing the #!. This will fix the
problem, or at least unmask another one ;).

heynnema
Junior
Posts: 16
Joined: Tue Apr 26, 2016 4:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by heynnema » Sun May 08, 2016 6:50 pm

bill6502... well... you're a genius! After removing the 4 spaces in front of the shebang, and the other lines of script, in hdhomerun.sh now works from the hdhomerun.service (in /run/systemd/system)! I moved hdhomerun.service into /etc/systemd/system and did a sudo systemctl enable hdhomerun.service. Tested it and it worked fine. Edited the .service to include the "Requires=hdhomerun.service", did a sudo systemctl daemon-reload, rebooted again, checked the operation, and it's all working!

Your logic is perfect. Mythtv-backend won't start until hdhomerun.service finds the tuners. And all this came about because I installed a SSD!

Cheers, Al

heynnema
Junior
Posts: 16
Joined: Tue Apr 26, 2016 4:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by heynnema » Sun May 08, 2016 6:52 pm

bill6502... thanks again for all of your knowledge and help!

Cheers, Al

User avatar
bill6502
Developer
Posts: 1377
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by bill6502 » Mon May 09, 2016 5:46 pm

Good to hear it worked out. If it's working well, please update the Subject:
and add [Solved] so that others looking at the forum will know.

Actually, you solved it by spotting the leading spaces!

heynnema
Junior
Posts: 16
Joined: Tue Apr 26, 2016 4:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tun [Solved]

Post by heynnema » Mon May 09, 2016 10:23 pm

Problem solved. Thanks to everybody for their help, esp. bill6502!

Cheers, Al

jaspersk
Newcomer
Posts: 1
Joined: Sat May 14, 2016 10:34 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by jaspersk » Sat May 14, 2016 10:41 pm

I had this same problem. I found this to be an error in the mythbackend.service

The solution above will work but there is not need to create a new service. An easier solution is to just make sure mythbackend doesn't start until the network is up.

Simply edit /etc/systemd/system/mythbackend.service
If it is not there, copy the default file to that directory from /lib/systemd/system

The default file has a line that says something like:
After=network.target

You simply need to add:
network-online.target

So it says:
After=network.target network-online.target

alforddm
Newcomer
Posts: 10
Joined: Mon May 23, 2016 5:05 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by alforddm » Mon May 23, 2016 6:28 pm

I'm glad I found this thread. This has been driving me nuts. However, I still don't have it working.

I tried this

You could do this. Make sure you understand every command below before starting:
verify that the custom service doesn't exist: ls -l /etc/systemd/system/mythtv-backend.service
stop the backend: systemctl stop mythtv-backend
(the next command isn't needed if you've found the file there already)
copy the existing service: sudo systemctl cat mythtv-backend.service > /etc/systemd/system/mythtv-backend.service
add: ExecPreStart=sleep 10 (or append: ;sleep 10 to an existing ExecPreStart line)
reload: sudo systemctl daemon-reload
restart the backend: systemctl start mythtv-backend
and
Simply edit /etc/systemd/system/mythbackend.service
If it is not there, copy the default file to that directory from /lib/systemd/system

The default file has a line that says something like:
After=network.target

You simply need to add:
network-online.target

So it says:
After=network.target network-online.target
Neither work for me. The backend just does not find the tuners on restart. This is what I have been doing to get it to work. sudo killall mythbackend and then run mythbackend. After this I can watch livetv and record.

This is a fresh install (well fresh as in a couple of days old but I've had this problem since install) of mythbuntu 16.04. I am using the hdhomerun3 and it is direcly connected to the computer by having the ethernet port set to local only.

Any suggestions would be appreciated. Thank you.

icemaniac
Newcomer
Posts: 5
Joined: Sat Jun 25, 2016 12:41 am
Iceland

Re: Backend requires restart to recognize hdhomerun tuners

Post by icemaniac » Sat Jul 30, 2016 6:54 pm

I'm having the same problem, SSD, fresh install of Ubuntu 16.04, HDHomeRun, etc. Seems like it is likely a network being unavailable in some form but following the advice here I have not been able to get it working. Any suggestions?

User avatar
bill6502
Developer
Posts: 1377
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by bill6502 » Sat Jul 30, 2016 11:03 pm

icemaniac wrote:I'm having the same problem, SSD, fresh install of Ubuntu 16.04, HDHomeRun, etc. Seems like it is likely a network being unavailable in some form but following the advice here I have not been able to get it working. Any suggestions?
Hi,

Sure, the HDHR service on the 1st page of this post has been
rock solid for me. But confirm that it's a network issue first.

If you restart the backend after a boot, the problem will go
ways. That's the signature of this issue.

If that isn't the case, please look in the backend log to see
what, if anything, fails. Open a new post if the subject is
different.

If it is the same, then post the output of:

Code: Select all

systemctl cat hdhomerun.service
systemctl status hdhomerun.service
Plus the same for the mythtv-backend.service
and the most recent failing backend log.

icemaniac
Newcomer
Posts: 5
Joined: Sat Jun 25, 2016 12:41 am
Iceland

Re: Backend requires restart to recognize hdhomerun tuners

Post by icemaniac » Tue Aug 02, 2016 12:00 am

Ok, I worked through one issue that was tripping me up but I'm still not quite there.

Issue 1:When running hdrhomerun.sh I got "hdhomerun_config: not found"
Cause: I didn't have hdhomerun-config installed
Fix: sudo apt-get install hdhomerun-config

Issue 2: hdhomerun.service is not starting and is required for mythtv-backend.service
Cause: for some reason "/usr/local/bin/hdhomerun.sh" runs fine when run in command line but not during startup from the hdhomerun.service
Fix: ???

systemctl cat hdhomerun.service

Code: Select all

# /etc/systemd/system/hdhomerun.service
[Unit]
Description=HD Homerun Discovery
Before=mythtv-backend.service
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/hdhomerun.sh

[Install]
WantedBy=default.target
systemctl status hdhomerun.service

Code: Select all

● hdhomerun.service - HD Homerun Discovery
   Loaded: loaded (/etc/systemd/system/hdhomerun.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2016-08-01 16:54:28 MST; 2min 1s ago
  Process: 1300 ExecStart=/usr/local/sbin/hdhomerun.sh (code=exited, status=203/EXEC)
 Main PID: 1300 (code=exited, status=203/EXEC)

Aug 01 16:54:28 bragi systemd[1]: Starting HD Homerun Discovery...
Aug 01 16:54:28 bragi systemd[1]: hdhomerun.service: Main process exited, code=exited, status=203/EXEC
Aug 01 16:54:28 bragi systemd[1]: Failed to start HD Homerun Discovery.
Aug 01 16:54:28 bragi systemd[1]: hdhomerun.service: Unit entered failed state.
Aug 01 16:54:28 bragi systemd[1]: hdhomerun.service: Failed with result 'exit-code'.
systemctl cat mythtv-backend.service

Code: Select all

# /etc/systemd/system/mythtv-backend.service
[Unit]
Description=MythTV Backend
Documentation=https://www.mythtv.org/wiki/Mythbackend
After=mysqld.service network.target
Requires=hdhomerun.service 
 
[Service]
User=mythtv
EnvironmentFile=-/etc/mythtv/additional.args
ExecStart=/usr/bin/mythbackend --quiet --syslog local7 $ADDITIONAL_ARGS
StartLimitBurst=10
StartLimitInterval=10m
Restart=on-failure
RestartSec=1
 
[Install]
WantedBy=multi-user.target
ystemctl status mythtv-backend.service

Code: Select all

 mythtv-backend.service - MythTV Backend
   Loaded: loaded (/etc/systemd/system/mythtv-backend.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: https://www.mythtv.org/wiki/Mythbackend

Aug 01 16:54:28 bragi systemd[1]: Dependency failed for MythTV Backend.
Aug 01 16:54:28 bragi systemd[1]: mythtv-backend.service: Job mythtv-backend.service/start failed with res

User avatar
bill6502
Developer
Posts: 1377
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by bill6502 » Tue Aug 02, 2016 12:24 am

Just one or two more steps. The answer is in the output of: systemctl status hdhomerun.service
where it says:

Loaded: loaded (/etc/systemd/system/hdhomerun.service; disabled; vendor preset: enabled

Use: sudo systemctl enable hdhomerun.service

It wouldn't hurt to do: sudo systemctl daemon-reload

icemaniac
Newcomer
Posts: 5
Joined: Sat Jun 25, 2016 12:41 am
Iceland

Re: Backend requires restart to recognize hdhomerun tuners

Post by icemaniac » Tue Aug 02, 2016 4:49 am

I think I stumbled across the issue:

In etc/systemd/system/hdhomerun.service I needed to change:

Code: Select all

ExecStart=/usr/local/[b]sbin[/b]/hdhomerun.sh
To:

Code: Select all

ExecStart=/usr/local/[b]bin[/b]/hdhomerun.sh

Looks to be working now, I really appreciate the elegance of waiting for the hdhomerun to be found rather than setting some arbitrary delay. Also, really appreciate the help bill6502. Thanks!!!

User avatar
bill6502
Developer
Posts: 1377
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by bill6502 » Tue Aug 02, 2016 3:00 pm

Good catch. I changed my initial instructions on page 1 to use /usr/bin
rather than sbin.

dirtprof
Newcomer
Posts: 1
Joined: Sat Sep 03, 2016 7:47 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by dirtprof » Sat Sep 03, 2016 7:56 pm

This is just a quick "thank you" to bill6502 for this elegant and effective fix. Irregular recording success had been plaguing me for months, and now my HDHomeRun tuners are reliably initialized on each boot. Again, thank you! :D

barber107
Newcomer
Posts: 4
Joined: Wed Aug 17, 2016 1:16 pm
United States of America

Re: Backend requires restart to recognize hdhomerun tuners

Post by barber107 » Wed Sep 07, 2016 12:58 pm

I agree with dirtprof, this fixed saved me from going back to a Windows Media Center!!! I've now been enjoying a rock solid MythTV setup for a month and I love it!

Post Reply