Kodi Community Forum

Full Version: Reboot delaying unnecessarily? Read within!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
One cause of that problem is the use of the TVH_DELAY configuration in TVHeadend's upstart scripts. The below files offer up a solution:

Code:
# 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

expect fork
respawn

pre-start script
  [ -r /etc/default/tvheadend ] && . /etc/default/tvheadend
  if [ "$TVH_ENABLED" != "1" ] ; then
    stop
    exit 0
  fi

  [ -z "${TVH_DELAY_DVB}" ] && TVH_DELAY_DVB=0
  for n in $(seq 1 ${TVH_DELAY_DVB}) ; do
    DEVICES="$(find /dev -type c -path '/dev/dvb/adapter*/frontend*' | wc -l)"
    [ ${DEVICES} -gt 0 ] && break
    sleep 1 || true
  done
end script

script
  [ -r /etc/default/tvheadend ] && . /etc/default/tvheadend
  if [ "$TVH_ENABLED" != "1" ] ; then
    stop
    exit 0
  fi

  ARGS="-f"
  [ -z "$TVH_USER"      ] || ARGS="$ARGS -u $TVH_USER"
  [ -z "$TVH_GROUP"     ] || ARGS="$ARGS -g $TVH_GROUP"
  [ -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_CONF_DIR"  ] || ARGS="$ARGS -c $TVH_CONF_DIR"


  exec tvheadend $ARGS $TVH_ARGS
end script

And the following variable must be added to /etc/default/tvheadend (can replace the old TVH_DELAY variable, which is no longer used):

Code:
# TVH_DELAY_DVB
#   The maximum number of seconds to wait for DVB hardware to become available.
#   Devices will be sought (using find) in /dev/dvb/adapter*/frontend* every second
#   until at least one becomes available, or the timer expires. At that point, startup
#   will continue normally. This has the added benefit of allowing hardware to initialize
#   prior to startup, but also eliminating the delay altogether when it is not needed, or
#   cutting it short as appropriate.
TVH_DELAY_DVB="30"

These changes will make the upstart script wait for up to 30 seconds for hardware to become available, and then continue startup. If no hardware becomes available, then startup is still performed regardless. However, the 30 second wait can be cut short the minute DVB devices become available. This means that it is also possible for no delay to be incurred whatsoever under optimal circumstances.

Hopefully, this will help someone out there. They've already been posted to the main TVH forums, so hopefully they'll get merged into the main branch (or superseded by something better). I post them here b/c although they're TVH issues, this information can be useful to others who may be running into the same problems as I was.

Cheers!