Merge branch '2.3.x' of dev.sourcefabric.org:airtime into 2.3.x

This commit is contained in:
Daniel James 2013-04-02 17:38:20 +01:00
commit 49929495f7
5 changed files with 77 additions and 44 deletions

View File

@ -17,19 +17,24 @@ DAEMON=/usr/lib/airtime/media-monitor/airtime-media-monitor
PIDFILE=/var/run/airtime-media-monitor.pid
start () {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
monit monitor airtime-media-monitor >/dev/null 2>&1
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
}
stop () {
# Send TERM after 5 seconds, wait at most 30 seconds.
monit unmonitor airtime-media-monitor >/dev/null 2>&1
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}
start_no_monit() {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
start_with_monit() {
start
monit monitor airtime-media-monitor >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-media-monitor >/dev/null 2>&1
stop
}
@ -53,10 +58,16 @@ case "${1:-''}" in
start
echo "Done."
;;
'start-no-monit')
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_no_monit
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
'status')

View File

@ -16,6 +16,6 @@ try:
#Start media-monitor daemon
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
print "* Waiting for media-monitor processes to start..."
subprocess.call("invoke-rc.d airtime-media-monitor start-no-monit", shell=True)
subprocess.call("invoke-rc.d airtime-media-monitor start", shell=True)
except Exception, e:
print e

View File

@ -17,22 +17,6 @@ DAEMON=/usr/lib/airtime/pypo/bin/airtime-liquidsoap
PIDFILE=/var/run/airtime-liquidsoap.pid
start () {
start_no_monit
monit monitor airtime-liquidsoap >/dev/null 2>&1
}
stop () {
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
#send term signal after 10 seconds
timeout -k 5 10 /usr/lib/airtime/airtime_virtualenv/bin/python \
/usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
# Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
sleep 3
}
start_no_monit() {
chown pypo:pypo /var/log/airtime/pypo
chown pypo:pypo /var/log/airtime/pypo-liquidsoap
chown pypo:pypo /etc/airtime/liquidsoap.cfg
@ -45,21 +29,43 @@ start_no_monit() {
--pidfile $PIDFILE --nicelevel -15 --startas $DAEMON
}
stop () {
#send term signal after 10 seconds
timeout -k 5 10 /usr/lib/airtime/airtime_virtualenv/bin/python \
/usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py
# Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
sleep 3
}
start_with_monit () {
start
monit monitor airtime-liquidsoap >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-liquidsoap >/dev/null 2>&1
stop
}
case "${1:-''}" in
'stop')
echo -n "Stopping Liquidsoap: "
echo -n "Stopping $NAME: "
stop
echo "Done."
;;
'start')
echo -n "Starting Liquidsoap: "
echo -n "Starting $NAME: "
start
echo "Done."
;;
'restart')
# restart commands here
echo -n "Restarting Liquidsoap: "
echo -n "Restarting $NAME: "
stop
start
echo "Done."
@ -69,22 +75,28 @@ case "${1:-''}" in
if [ -f "$PIDFILE" ]; then
pid=`cat $PIDFILE`
if [ -d "/proc/$pid" ]; then
echo "Liquidsoap is running"
echo "$NAME is running"
exit 0
fi
fi
echo "Liquidsoap is not running"
echo "$NAME is not running"
exit 1
;;
'start-no-monit')
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_no_monit
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart"
echo "Usage: $SELF start|stop|restart|status"
exit 1
;;

View File

@ -10,7 +10,7 @@
### END INIT INFO
USERID=root
NAME="Airtime Scheduler Engine"
NAME="Airtime Scheduler"
DAEMON=/usr/lib/airtime/pypo/bin/airtime-playout
PIDFILE=/var/run/airtime-playout.pid
@ -18,21 +18,24 @@ PIDFILE=/var/run/airtime-playout.pid
start () {
chown pypo:pypo /etc/airtime
chown pypo:pypo /etc/airtime/liquidsoap.cfg
start-stop-daemon --start --background --quiet --chuid $USERID:$USERID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
monit monitor airtime-playout >/dev/null 2>&1
start-stop-daemon --start --background --quiet --chuid $USERID:$USERID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
}
stop () {
# Send TERM after 5 seconds, wait at most 30 seconds.
monit unmonitor airtime-playout >/dev/null 2>&1
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}
start_no_monit() {
start-stop-daemon --start --background --quiet --chuid $USERID:$USERID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
start_with_monit() {
start
monit monitor airtime-playout >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-playout >/dev/null 2>&1
stop
}
case "${1:-''}" in
@ -55,12 +58,19 @@ case "${1:-''}" in
start
echo "Done."
;;
'start-no-monit')
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_no_monit
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
'status')
# status commands here
/usr/bin/airtime-check-system

View File

@ -88,8 +88,8 @@ try:
if "airtime_service_start" in os.environ and os.environ["airtime_service_start"] == "t":
print "* Waiting for pypo processes to start..."
subprocess.call("invoke-rc.d airtime-playout start-no-monit > /dev/null 2>&1", shell=True)
subprocess.call("invoke-rc.d airtime-liquidsoap start-no-monit > /dev/null 2>&1", shell=True)
subprocess.call("invoke-rc.d airtime-playout start > /dev/null 2>&1", shell=True)
subprocess.call("invoke-rc.d airtime-liquidsoap start > /dev/null 2>&1", shell=True)
except Exception, e:
print e