Gentoo Archives: gentoo-commits

From: "Matthias Schwarzott (zzam)" <zzam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-vdr r604 - in gentoo-vdr-scripts/trunk: . usr/sbin
Date: Thu, 29 May 2008 16:07:03
Message-Id: E1K1keX-0004N2-WA@stork.gentoo.org
1 Author: zzam
2 Date: 2008-05-29 16:06:57 +0000 (Thu, 29 May 2008)
3 New Revision: 604
4
5 Removed:
6 gentoo-vdr-scripts/trunk/usr/sbin/vdr-inform-watchdog.sh
7 Modified:
8 gentoo-vdr-scripts/trunk/ChangeLog
9 gentoo-vdr-scripts/trunk/usr/sbin/vdr-watchdogd
10 Log:
11 Rewrite of vdr-watchdog.
12
13 Modified: gentoo-vdr-scripts/trunk/ChangeLog
14 ===================================================================
15 --- gentoo-vdr-scripts/trunk/ChangeLog 2008-05-21 12:00:21 UTC (rev 603)
16 +++ gentoo-vdr-scripts/trunk/ChangeLog 2008-05-29 16:06:57 UTC (rev 604)
17 @@ -1,6 +1,10 @@
18 # ChangeLog for gentoo-vdr-scripts
19 # $Id$
20
21 + 29 May 2008; Matthias Schwarzott <zzam@g.o>
22 + -usr/sbin/vdr-inform-watchdog.sh, usr/sbin/vdr-watchdogd:
23 + Rewrite of vdr-watchdog.
24 +
25 21 May 2008; Matthias Schwarzott <zzam@g.o>
26 vdrplugin-rebuild/vdrplugin-rebuild:
27 Do not produce errors when no plugins were skipped at last start.
28
29 Deleted: gentoo-vdr-scripts/trunk/usr/sbin/vdr-inform-watchdog.sh
30 ===================================================================
31 --- gentoo-vdr-scripts/trunk/usr/sbin/vdr-inform-watchdog.sh 2008-05-21 12:00:21 UTC (rev 603)
32 +++ gentoo-vdr-scripts/trunk/usr/sbin/vdr-inform-watchdog.sh 2008-05-29 16:06:57 UTC (rev 604)
33 @@ -1,4 +0,0 @@
34 -#!/bin/sh
35 -# $Id$
36 -"$@"
37 -killall -q --signal HUP vdr-watchdogd
38
39 Modified: gentoo-vdr-scripts/trunk/usr/sbin/vdr-watchdogd
40 ===================================================================
41 --- gentoo-vdr-scripts/trunk/usr/sbin/vdr-watchdogd 2008-05-21 12:00:21 UTC (rev 603)
42 +++ gentoo-vdr-scripts/trunk/usr/sbin/vdr-watchdogd 2008-05-29 16:06:57 UTC (rev 604)
43 @@ -13,43 +13,86 @@
44 exec >/dev/null 2>&1
45
46 . /etc/conf.d/vdr.watchdogd
47 +DEBUG=1
48 +[ "$1" = "--debug" ] && DEBUG=1
49 +
50 if [ "${DEBUG}" = 1 ]; then
51 - exec >/tmp/vdrwatchdogd-log 2>&1
52 + exec >/tmp/vdr-watchdogd.log 2>&1
53 date
54 set -x
55 fi
56
57 +exit_handler() {
58 + run=0
59 + enabled=0
60 +}
61 +
62 +on_handler() {
63 + log "Enabled by USR1"
64 + enabled=1
65 +}
66 +
67 +off_handler() {
68 + log "Disabled by USR2"
69 + enabled=0
70 +}
71 +
72 +noop() {
73 + :
74 +}
75 +
76 +trap exit_handler INT QUIT TERM
77 +trap on_handler USR1
78 +trap off_handler USR2
79 +trap noop HUP
80 +
81 +# hack to allow getting a signal handled immediately
82 +run_child() {
83 + $@ &
84 + child_pid=$!
85 + wait || kill $child_pid
86 +}
87 +
88 log() {
89 logger -i -t vdrwatchdog -p local0.info "$@"
90 }
91
92 -do_restart() {
93 +trigger_restart() {
94 log "restarting VDR"
95 /etc/init.d/vdr watchdogrestart
96 log "VDR has been restarted"
97 - /usr/bin/svdrpsend.pl mesg "Warning: vdr was restarted by watchdog." &
98 + svdrpsend.pl mesg "Warning: vdr was restarted by watchdog." &
99 }
100
101 -is_paused() {
102 - [ -f /tmp/vdr-nowatchdog ]
103 +is_enabled() {
104 + [ $enabled = 0 ] && return 1
105 + [ -f /tmp/vdr-nowatchdog ] && return 1
106 +
107 + return 0
108 }
109
110 VDR=/usr/bin/vdr
111
112 -log "Starting vdrwatchdog"
113 -while true; do
114 - pid=$(pidof -s ${VDR})
115 - if [ -n "${pid}" ]; then
116 - /usr/bin/wait_on_pid "${pid}"
117 - fi
118 +main() {
119 + log "Starting vdrwatchdog"
120 + run=1
121 + enabled=1
122 + while [ "${run}" = "1" ]; do
123 + if ! is_enabled; then
124 + run_child sleep 10
125 + continue
126 + fi
127
128 - while is_paused; do
129 - sleep 10
130 + pid=$(pidof -s ${VDR})
131 + if [ -n "${pid}" ]; then
132 + run_child wait_on_pid "${pid}"
133 + # pid exited, check at next loop
134 + else
135 + trigger_restart
136 + fi
137 done
138 -
139 - if ! pidof ${VDR} >/dev/null; then
140 - do_restart
141 - fi
142 -done
143 -log "Exiting vdrwatchdog"
144 + log "Exiting vdrwatchdog"
145 +}
146
147 +main
148 +
149
150 --
151 gentoo-commits@l.g.o mailing list