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

My Tvheadend server stopped restarting after power loss.

Original problem and solution can be found here (thread was closed so I couldn’t post there):

Since then I’ve updated to the latest version of CoreElec Matrix and updated Cabernet.
(Details of Cabernet can be found at PlutoTV, USTVGO, XUMO, M3U/XMLTV, SamsungTV, Plex interfaces (appliance) - Tvheadend)
I don’t think the Cabernet update has anything to do with it but I thought I’d let it be known.

The service file still looks the same as modified in the other thread. The Tvheadend server starts after I do a reboot as it did with the original problem.

Any suggestions?

Again use this command when service doesn’t start and post the result

systemctl status service.tvheadend42.service -l

The TVHeadent has been disabled on the Beelink GT Pro device.

/storage$ systemctl status service.tvheadend43.service -l
● service.tvheadend43.service - TVHeadend43 Service
     Loaded: loaded (/storage/.kodi/addons/service.tvheadend43/system.d/service.tvheadend43.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2021-11-14 21:33:40 +03; 2h 58min ago
   Main PID: 4921 (tvheadend)
      Tasks: 42 (limit: 3836)
     Memory: 84.8M
     CGroup: /system.slice/service.tvheadend43.service
             └─4921 /storage/.kodi/addons/service.tvheadend43/bin/tvheadend -B -C -u root -g video -c /storage/.kodi/userdata/addon_data/service.tvheadend43

Nov 15 00:30:55 CoreELEC tvheadend[4921]: linuxdvb: Silicon Labs Si2183 #0 : DVB-S #0 - FE_READ_STATUS error Connection timed out
Nov 15 00:30:58 CoreELEC tvheadend[4921]: mpegts: too much queued table input data (over 2MB) for Silicon Labs Si2183 #0 : DVB-S #0, discarding new
Nov 15 00:31:08 CoreELEC tvheadend[4921]: mpegts: too much queued table input data (over 2MB) for Silicon Labs Si2183 #0 : DVB-S #0, discarding new
Nov 15 00:31:18 CoreELEC tvheadend[4921]: mpegts: too much queued table input data (over 2MB) for Silicon Labs Si2183 #0 : DVB-S #0, discarding new
Nov 15 00:31:28 CoreELEC tvheadend[4921]: mpegts: too much queued table input data (over 2MB) for Silicon Labs Si2183 #0 : DVB-S #0, discarding new
Nov 15 00:31:33 CoreELEC tvheadend[4921]: TS: TURKSAT 4A 42E/11789H/SİNEMA AKSİYON 2 Transport error indicator (total 1)
Nov 15 00:31:34 CoreELEC tvheadend[4921]: TS: TURKSAT 4A 42E/11789H/SİNEMA AKSİYON 2: H264 @ #4655 Continuity counter error (total 1)
Nov 15 00:31:37 CoreELEC tvheadend[4921]: TS: TURKSAT 4A 42E/11789H/SİNEMA AKSİYON 2: MPEG2AUDIO @ #4755: Invalid start code 30:5f:09
Nov 15 00:31:37 CoreELEC tvheadend[4921]: TS: TURKSAT 4A 42E/11789H/SİNEMA AKSİYON 2: H264 @ #4655: Invalid start code 82:be:a0
Nov 15 00:31:37 CoreELEC tvheadend[4921]: linuxdvb: Silicon Labs Si2183 #0 : DVB-S #0 - FE_READ_STATUS error Connection timed out

As you can see it is running. And seems you have some different issue.

1 Like

is disabled from time to time while working. Needs to cut electricity to activate. Does not be activated with reboot .

Then you need to check at that time why it was disabled. Maybe crashed.

I think the USB port is disabled.

After pulling the plug and restarting:

 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 Fri 2021-08-06 07:43:09 PDT; 3 months 9 days ago
   Main PID: 4046 (tvheadend)
      Tasks: 25 (limit: 1735)
     Memory: 247.3M
     CGroup: /system.slice/service.tvheadend42.service
             ├─4046 /storage/.kodi/addons/service.tvheadend42/bin/tvheadend -B -C -u root -g video -c /storage/.kodi/userdata/addon_data/service.tvheadend42
             ├─6008 sh /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url -u http://192.168.1.83:6077/xmltv.xml
             └─6009 wget -q -T 60 -O - http://192.168.1.83:6077/xmltv.xml

Nov 15 06:41:17 CoreELEC tvheadend[4046]: epgdb: snapshot start
Nov 15 06:41:18 CoreELEC tvheadend[4046]: epgdb: queued to save (size 30737763)
Nov 15 06:41:18 CoreELEC tvheadend[4046]: epgdb:   brands     0
Nov 15 06:41:18 CoreELEC tvheadend[4046]: epgdb:   seasons    1546
Nov 15 06:41:18 CoreELEC tvheadend[4046]: epgdb:   episodes   20155
Nov 15 06:41:18 CoreELEC tvheadend[4046]: epgdb:   broadcasts 37687
Nov 15 06:41:18 CoreELEC tvheadend[4046]: dvr: "Rick Steves' Europe" on "KVIEHD" recorder starting
Nov 15 06:41:18 CoreELEC tvheadend[4046]: dvr: About to set stop timer for "Rick Steves' Europe" on "KVIEHD" at start 1635202800 and original stop 1635204600 and overal
Nov 15 06:43:10 CoreELEC tvheadend[4046]: xmltv: /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url: grab /storage/.kodi/addons/service.tvheadend42/bin/tv_grab_u
Nov 15 06:43:10 CoreELEC tvheadend[4046]: spawn: Executing "/storage/.kodi/addons/service.tvheadend42/bin/tv_grab_url"

After subsequently rebooting:

 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 Mon 2021-11-15 06:51:13 PST; 1min 37s ago
   Main PID: 4039 (tvheadend)
      Tasks: 34 (limit: 1735)
     Memory: 249.0M
     CGroup: /system.slice/service.tvheadend42.service
             └─4039 /storage/.kodi/addons/service.tvheadend42/bin/tvheadend -B -C -u root -g video -c /storage/.kodi/userdata/addon_data/service.tvheadend42

Nov 15 06:51:41 CoreELEC tvheadend[4039]: htsp: Got connection from 127.0.0.1
Nov 15 06:51:41 CoreELEC tvheadend[4039]: htsp: 127.0.0.1: Welcomed client software: Kodi Media Center (HTSPv34)
Nov 15 06:51:41 CoreELEC tvheadend[4039]: htsp: 127.0.0.1 [ Kodi Media Center ]: Identified as user ''
Nov 15 06:51:42 CoreELEC tvheadend[4039]: iptv: m3u parse: 0 new mux(es) in network 'Pluto TV' (total 342)
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: DVB-S - loaded 1 regions with 115 networks
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: DVB-T - loaded 44 regions with 1120 networks
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: DVB-C - loaded 19 regions with 63 networks
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: ATSC-T - loaded 2 regions with 12 networks
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: ATSC-C - loaded 1 regions with 5 networks
Nov 15 06:51:44 CoreELEC tvheadend[4039]: scanfile: ISDB-T - loaded 2 regions with 1297 networks

I don’t see anything wrong here?

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