Bug #1718
/etc/default/tvheadend - delay setting causes the shutdown or reboot 5mins slower
0%
Description
Hi,
My system: Mini Ubuntu 12.04 with HTS Tvheadend 3.5.103~g54d9751
Front End: XBMC Frodo
Issue to me: Any seconds I set the delay my shutdown or reboot takes 5 minutes. If I set the delay back to ="" my shutdown and reboot only takes under between 6 to 12 seconds.
If I power on the system from a powered down system. It takes 15 seconds to boot.. No problem here. Meaning nothing is changed - its normal boot time.
Something is happening on shutdown or reboot that I can't tell.
Not sure what log you need, please let me know.
History
Updated by Ryan Baray over 11 years ago
I use the delay setting because if I have it set on ="" it does not detect my adapter0 and frontend0. TVheadend is to fast that my adapter hasn't load the firmware yet.
Don't get me wrong, the delay works, my only issue is when I shutdown the system or reboot it takes 5 mins.
Updated by Ryan Baray over 11 years ago
Ryan Baray wrote:
I use the delay setting because if I have it set on ="" it does not detect my adapter0 and frontend0. TVheadend is to fast that my adapter hasn't load the firmware yet.
Don't get me wrong, the delay works, my only issue is when I shutdown the system or reboot it takes 5 mins.
Just an update.
I've been digging around with the tvheadend upstart and could not understand why the shutdown is increasing dramatically to more than 20mins now.
So, what I did for now is disabled the tvheadend upstart and edit the rc.local to sleep then run /usr/local/bin/tvheadend - ALL is GOOD
Updated by Adam Sutton over 11 years ago
- Status changed from New to Rejected
This sounds like a problem with upstart to me, all setting that delay param does is add a sleep just before calling tvheadend. This should have ZERO effect on shutdown.
Adam
Updated by Diego Rivera over 11 years ago
The problem is, as has been stated, with upstart - but not upstart per-se. The problem is the upstart configuration packaged with TVHeadend.
The existing configuration uses an "expect fork" stanza incorrectly. As per upstart documentation, "expect fork" or "expect daemon" should only be used if the starting process invokes fork() exactly once (expect fork) or twice (expect daemon). Otherwise, it should not be used AT ALL. TVH does neither when using the -f parameter, and thus should not use this stanza. Instead, run it in the foreground and let upstart manage the process.
This immediately puts a chink in the armor because now the user which TVHeadend will run as will no longer be configurable without modifying the upstart configuration file directly (specifically, the setuid stanza and the "~hts" portion of the configuration directory).
I've managed to resolve this issue by using the following configuration file:
# tvheadend - DVB/IPTV streaming server # # Tvheadend is a TV streaming server for Linux supporting DVB, ATSC, IPTV, # and Analog video (V4L) as input sources. description "Tvheadend DVB/IPTV streaming server" author "Adam Sutton <[email protected]>" start on (local-filesystems and net-device-up and started udev-finish) stop on starting shutdown setuid hts setgid video respawn script [ -r /etc/default/tvheadend ] && . /etc/default/tvheadend if [ "$TVH_ENABLED" != "1" ] ; then stop exit 0 fi CONF="$(readlink -f ~hts/.hts/tvheadend)" [ -n "$TVH_CONF_DIR" ] && CONF="-c $TVH_CONF_DIR" ARGS="-c ${CONF}" [ -z "$TVH_ADAPTERS" ] || ARGS="$ARGS -a $TVH_ADAPTERS" [ "$TVH_IPV6" = "1" ] && ARGS="$ARGS -6" [ -z "$TVH_HTTP_PORT" ] || ARGS="$ARGS --http_port $TVH_HTTP_PORT" [ -z "$TVH_HTTP_ROOT" ] || ARGS="$ARGS --http_root $TVH_HTTP_ROOT" [ -z "$TVH_HTSP_PORT" ] || ARGS="$ARGS --htsp_port $TVH_HTSP_PORT" [ "$TVH_DEBUG" = "1" ] && ARGS="$ARGS -s" [ ! -z "$TVH_DELAY" ] && sleep $TVH_DELAY exec tvheadend $ARGS $TVH_ARGS end script
This corrects the start/stop delay problem, and allows upstart to properly manage the TVHeadend process. However, if there is a need to change the user that TVH runs as (like XBMCbuntu does), then the init configuration will have to be edited as the setuid/setgid stanzas are not dynamic and can't be configured based on a variable.
This fixed the problems 100% for me. However, it requires that your Linux install have upstart 1.4 or newer installed (for setuid/setgid support).
Hope this helps!
Updated by Adam Sutton over 11 years ago
Your statement is incorrect. TVH call fork() exactly once, indirectly, via the daemon() call. Much of the single/double fork nonsense is historic and down to potential for things to not go entirely as expected with a single fork. But if I get a chance I'll try and take a look. Though I'm pretty sure I tried repeating this with no luck.
To be honest that delay option really needs removing anyway and hopefully will in 4.0.
Adam