Bug #1777
New Upstart config waits for /dev/dvb hardware to be available
0%
Description
Ok this is the last one I post on this topic
I've come up with a better solution to the TVH_DELAY problem - a script that will actually wait for hardware in /dev/dvb/* to become available (which was the point of it all to begin with) prior to continuing with TVH startup, for up to a configurable delay (I recommend the configurable default to be 30 seconds). This means that the delay will only be applied while that hardware is not available. If it's available, startup is immediate. This should solve both the issue by only applying the delay when needed, while giving the option to "semi-synchronize" initialization allowing for hardware delays.
Evidently, this will be rendered moot if such functionality is provided as part of the base executable.
Here is the 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
Evidently, a new variable must be added to /etc/default/tvheadend in place of TVH_DELAY:
# 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"I've been testing this quite extensively and this should do nicely for the following reasons:
- Allows for a delay to permit hardware initialization
- The delay can be cut short as soon as "a" hardware becomes available
- If hardware is already available, the delay is cut to 0
- Removes the sleep invocation that confused upstart so badly (by moving it to a pre-start script)
- Should bridge the gap nicely and afford additional time for a more complete implementation to come from the code.
By "a more complete implementation" I mean an implementation within TVH which is dynamically adding/removing hardware as it becomes available/disappears. This is likely a tall order, and will probably be low on the priority list since something like the above solution makes things livable for the time being.
Hope you find this useful.
Cheers.
PS/ I really truly promise this is my last post on this particular subject
History
Updated by Adam Sutton almost 11 years ago
- Status changed from New to Rejected
I'm going to close this as the need for it will soon, once I find a day or so to finish off the code, become redundant.
Adam