restarting tvheadend after process crashes?
Added by Bernd Nebendahl over 4 years ago
Hello,
just recently I could not watch TV anymore. After checking on the machine where tvheadend is running (Linux tvserver 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux) I noticed that tvheadend was not running. I then manually restarted the service using "systemctl restart tvheadend.service". I then tried to find the file, where the service is defined but did only find "/etc/init.d/tvheadend". I would have expected a file in "/etc/systemd/system/". So here are my questions:
1. Is it expected that once tvheadend crashes it does not restart automatically?
2. How would I make tvheadend restart automatically once it crashes? Modify "/etc/init.d/tvheadend" or add a file to "/etc/systemd/system"?
3. Is there an example that someone can share? I don't feel that I know enough to fix this myself.
Thank you,
Bernd
Replies (4)
RE: restarting tvheadend after process crashes? - Added by Nick Sillito over 4 years ago
Im running tvheadend (4.3-1725~g9a6007c20) on ubuntu 19.10, and I have the file /etc/systemd/systemtvheadend.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
(and this was a standard install from the repository)
The line Restart=on-failure which makes systemd restart on a crash -- the functionality that you were looking for
RE: restarting tvheadend after process crashes? - Added by Bernd Nebendahl over 4 years ago
I switched to the latest unstable release now (Build: 4.3-1857~g221c29b40 (2019-11-28T18:14:55+0000)) and found the file described above. Is there a certain reason to set "RestartSec" to 54 seconds? Can one shorten that without problems?
Thanks,
Bernd
RE: restarting tvheadend after process crashes? - Added by Nick Sillito over 4 years ago
If not specified, RestartSec defaults to 0.1 second [[https://www.freedesktop.org/software/systemd/man/systemd.service.html]]
I assume that someone specified a different value for a good reason (maybe time to allow a capture device to disconnect from the crashed process?) I've never had an issue with tvheadend crashing so I've never tried changing the value.
RE: restarting tvheadend after process crashes? - Added by M. Bergmann almost 3 years ago
I just stumbled upon this entry:
54 seconds looks like a typo IMHO, perhaps it should have been 5 seconds ?