TVHeadend Server not restarting after power loss

I’m running a Ugoos X3 box as a TVHeadend Server (4.2 - v19.2.125).
When the box looses power CoreELEC will restart but the TVHeadend server doesn’t restart.
If I go into the Power menu and reboot TVHeadend server will then start after boot.
If I go into the TVHeadend server Configuration menu, make a change, and then exit, the TVHeadend server will start.

Any suggestions on how to make the TVHeadend server restart after a power loss?

You can try enable in CoreELEC settings->Network->Wait for network before starting Kodi

That was already set to 10 seconds. I tried setting it to 60 seconds with same results.

When it doesn’t start check

systemctl status service.tvheadend42.service -l

I get the text below when I execute the command. So it appears that the TVHeadend server is running but my clients can’t access it (including the TVHeadend client on the Ugoos box). And scheduled recordings are missed when it is in this state.

Also, the recordings referenced are zombie recordings from when I was testing the system. Is there an easy to get rid of them?

service.tvheadend42.service - TVHeadend42 Service
     Loaded: loaded (/storage/.kodi/addons/service.tvheadend42/system.d/service.tvheadend42.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2021-02-02 07:29:49 PST; 6 months 1 days ago
   Main PID: 3957 (tvheadend)
      Tasks: 27 (limit: 1735)
     Memory: 225.5M
     CGroup: /system.slice/service.tvheadend42.service
             ├─3957 /storage/.kodi/addons/service.tvheadend42/bin/tvheadend -B -C -u root -g video -c /storage/.kodi/userdata/addon_data/service.tvheadend42
             ├─5523 sh /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url -u http://192.168.1.83:6077/xmltv.xml
             └─5524 wget -q -T 20 -O - http://192.168.1.83:6077/xmltv.xml

Aug 05 07:52:52 CoreELEC tvheadend[3957]: subscription: 0001: "DVR: Hazel" unsubscribing from "Ant TV "
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: "Hazel" on "Ant TV ": End of program: Time missed
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: "Lauren Lake's Paternity Court" on "KTXL-TV" recorder starting
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: About to set stop timer for "Lauren Lake's Paternity Court" on "KTXL-TV" at start 1621285200 and original stop 1621287000
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: "Gimme a Break" on "Ant TV " recorder starting
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: About to set stop timer for "Gimme a Break" on "Ant TV " at start 1621285200 and original stop 1621287000 and overall sto
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: "Gimme a Break" on "Ant TV " recorder starting
Aug 05 07:52:52 CoreELEC tvheadend[3957]: dvr: About to set stop timer for "Gimme a Break" on "Ant TV " at start 1621287000 and original stop 1621288800 and overall sto
Aug 05 07:54:44 CoreELEC tvheadend[3957]: xmltv: /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url: grab /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_u
Aug 05 07:54:44 CoreELEC tvheadend[3957]: spawn: Executing "/storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url"

This looks wrong to me

Active: active (running) since Tue 2021-02-02 07:29:49 PST; 6 months 1 days ago

But then you can see today’s date

Aug 05 07:52:52 CoreELEC tvheadend[3957]: 

Maybe your time get wrong after power loose ? And if date/time is wrong tvh doesn’t working correctly.

Well, it also hasn’t been continuously running since 2021-02-02 either. That was the date I first got the system up and running. Shouldn’t it reset when I pull the power plug?

Right now for testing I’m just polling the power plug on the Ugoos box and nothing else. So if it isn’t getting the correct time it is something within the box.

Can you reboot the box and then type again above systemctl command?

 service.tvheadend42.service - TVHeadend42 Service
     Loaded: loaded (/storage/.kodi/addons/service.tvheadend42/system.d/service.tvheadend42.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2021-08-05 08:07:25 PDT; 38min ago
   Main PID: 3945 (tvheadend)
      Tasks: 34 (limit: 1735)
     Memory: 192.7M
     CGroup: /system.slice/service.tvheadend42.service
             └─3945 /storage/.kodi/addons/service.tvheadend42/bin/tvheadend -B -C -u root -g video -c /storage/.kodi/userdata/addon_data/service.tvheadend42

Aug 05 08:25:50 CoreELEC tvheadend[3945]: mpegts: 195.028MHz in ATSC-T Network - tuning on HDHomeRun ATSC-T Tuner #0 (192.168.1.65)
Aug 05 08:25:50 CoreELEC tvheadend[3945]: tvhdhomerun: tuning to auto:195028615
Aug 05 08:25:50 CoreELEC tvheadend[3945]: subscription: 0003: "192.168.1.97 [  | Kodi Media Center ]" subscribing on channel "KXTV", weight: 150, adapter: "HDHomeRun AT
Aug 05 08:25:51 CoreELEC tvheadend[3945]: timeshift: Unable to change directory permissions to "700" for "/var/media/USB Drive/Timeshift/buffer/2" (keeping "777")
Aug 05 08:40:14 CoreELEC tvheadend[3945]: subscription: 0003: "192.168.1.97 [  | Kodi Media Center ]" unsubscribing from "KXTV", hostname="192.168.1.97", username="192.
Aug 05 08:40:22 CoreELEC tvheadend[3945]: htsp: 192.168.1.97 [  | Kodi Media Center ]: Disconnected
Aug 05 08:42:21 CoreELEC tvheadend[3945]: htsp: Got connection from 192.168.1.97
Aug 05 08:42:21 CoreELEC tvheadend[3945]: htsp: 192.168.1.97: Welcomed client software: Kodi Media Center (HTSPv34)
Aug 05 08:42:21 CoreELEC tvheadend[3945]: htsp: 192.168.1.97 [ Kodi Media Center ]: Identified as user ''
Aug 05 08:43:42 CoreELEC tvheadend[3945]: htsp: 192.168.1.97 [  | Kodi Media Center ]: Disconnected

Can you replace file /storage/.kodi/addons/service.tvheadend42/system.d/service.tvheadend42.service with this content?

[Unit]
Description=TVHeadend42 Service
After=network-online.service time-sync.target
Wants=time-sync.target

[Service]
ExecStart=/bin/sh -c "exec sh /storage/.kodi/addons/service.tvheadend42/bin/tvheadend42.start"
TimeoutStopSec=2
Restart=always
RestartSec=2
StartLimitInterval=0

[Install]
WantedBy=kodi.target

Change file, make a reboot, check that everything works, cut power, check if it works after powering on.

1 Like

That did it!

Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice