From 79e24e5af51c13679fc03022aadbdd29f669ba11 Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 31 May 2011 16:05:48 -0400 Subject: [PATCH] cc-2055: switch to init.d -Change all python apps to log directly to file -change airtime-pypo to airtime-playback -fix airtime install started/completed message bumpers --- install/airtime-install | 22 ++++++---- install/airtime-install.php | 15 ------- ...r-daemontools.sh => airtime-media-monitor} | 8 ++-- .../media-monitor/airtime-media-monitor-start | 16 -------- .../media-monitor/airtime-media-monitor-stop | 28 ------------- .../media-monitor-daemontools-logger.sh | 2 - .../install/media-monitor-install.py | 29 ++------------ python_apps/media-monitor/logging.cfg | 10 ++--- ...tools-liquidsoap.sh => airtime-liquidsoap} | 0 .../pypo/{airtime-pypo => airtime-playout} | 0 ...ime-pypo-init-d => airtime-playout-init-d} | 2 +- .../pypo/install/pypo-daemontools-logger.sh | 2 - python_apps/pypo/install/pypo-daemontools.sh | 17 -------- python_apps/pypo/install/pypo-install.py | 40 +++---------------- .../pypo-liquidsoap-daemontools-logger.sh | 2 - python_apps/pypo/logging.cfg | 22 ++++++---- python_apps/pypo/pypo-cli.py | 1 + python_apps/pypo/pypo-log.sh | 15 ------- python_apps/pypo/pypopush.py | 21 ++++++---- python_apps/pypo/util/cue_file.py | 2 +- ...r-daemontools.sh => airtime-show-recorder} | 0 .../show-recorder/airtime-show-recorder-start | 16 -------- .../show-recorder/airtime-show-recorder-stop | 31 -------------- .../install/recorder-daemontools-logger.sh | 2 - .../show-recorder/install/recorder-install.py | 31 +++----------- python_apps/show-recorder/logging.cfg | 10 ++--- 26 files changed, 75 insertions(+), 269 deletions(-) rename python_apps/media-monitor/{install/media-monitor-daemontools.sh => airtime-media-monitor} (69%) delete mode 100755 python_apps/media-monitor/airtime-media-monitor-start delete mode 100755 python_apps/media-monitor/airtime-media-monitor-stop delete mode 100755 python_apps/media-monitor/install/media-monitor-daemontools-logger.sh rename python_apps/pypo/{install/pypo-daemontools-liquidsoap.sh => airtime-liquidsoap} (100%) rename python_apps/pypo/{airtime-pypo => airtime-playout} (100%) rename python_apps/pypo/{airtime-pypo-init-d => airtime-playout-init-d} (97%) delete mode 100755 python_apps/pypo/install/pypo-daemontools-logger.sh delete mode 100755 python_apps/pypo/install/pypo-daemontools.sh delete mode 100644 python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh delete mode 100755 python_apps/pypo/pypo-log.sh rename python_apps/show-recorder/{install/recorder-daemontools.sh => airtime-show-recorder} (100%) delete mode 100755 python_apps/show-recorder/airtime-show-recorder-start delete mode 100755 python_apps/show-recorder/airtime-show-recorder-stop delete mode 100755 python_apps/show-recorder/install/recorder-daemontools-logger.sh diff --git a/install/airtime-install b/install/airtime-install index 45253fc6e..0d88f03a3 100755 --- a/install/airtime-install +++ b/install/airtime-install @@ -1,13 +1,21 @@ -#!/bin/sh +#!/bin/bash -php airtime-install.php $@ || exit $? +#Cause bash script to exit if any of the installers +#return with a non-zero return value. +set -e + +echo -e "\n******************************** Install Begin *********************************"; + +php airtime-install.php $@ echo "*** Pypo Installation ***" -#python ".__DIR__."/../python_apps/pypo/install/pypo-install.py || exit $? -python ../python_apps/pypo/install/pypo-install.py || exit $? +#python ".__DIR__."/../python_apps/pypo/install/pypo-install.py +python ../python_apps/pypo/install/pypo-install.py -echo "*** Recorder Installation ***" -#python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py || exit $? -#python ../python_apps/show-recorder/install/recorder-install.py || exit $? +#echo "*** Recorder Installation ***" +#python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py +#python ../python_apps/show-recorder/install/recorder-install.py airtime-check-system + +echo -e "\n******************************* Install Complete *******************************"; diff --git a/install/airtime-install.php b/install/airtime-install.php index e5dfedd30..68d0ee916 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -10,9 +10,6 @@ */ set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path()); -echo PHP_EOL; -echo "******************************** Install Begin *********************************".PHP_EOL; - require_once(dirname(__FILE__).'/include/AirtimeIni.php'); require_once(dirname(__FILE__).'/include/AirtimeInstall.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php'); @@ -126,19 +123,7 @@ AirtimeInstall::CreateSymlinksToUtils(); AirtimeInstall::CreateZendPhpLogFile(); -#echo PHP_EOL."*** Pypo Installation ***".PHP_EOL; -#system("python ".__DIR__."/../python_apps/pypo/install/pypo-install.py"); - -#echo PHP_EOL."*** Recorder Installation ***".PHP_EOL; -#system("python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py"); - //wait for 1.9.0 release //echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL; //system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py"); -#echo PHP_EOL."*** Verifying Correct System Environment ***".PHP_EOL; -#$command = "airtime-check-system"; -#system($command); - -echo "******************************* Install Complete *******************************".PHP_EOL; - diff --git a/python_apps/media-monitor/install/media-monitor-daemontools.sh b/python_apps/media-monitor/airtime-media-monitor similarity index 69% rename from python_apps/media-monitor/install/media-monitor-daemontools.sh rename to python_apps/media-monitor/airtime-media-monitor index d629ec49d..a703ebc25 100755 --- a/python_apps/media-monitor/install/media-monitor-daemontools.sh +++ b/python_apps/media-monitor/airtime-media-monitor @@ -1,5 +1,4 @@ #!/bin/sh -media_monitor_user="pypo" # Location of pypo_cli.py Python script media_monitor_path="/usr/lib/airtime/media-monitor/" @@ -8,10 +7,11 @@ media_monitor_script="MediaMonitor.py" api_client_path="/usr/lib/airtime/pypo/" cd ${media_monitor_path} -echo "*** Daemontools: starting daemon" exec 2>&1 -# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr export PYTHONPATH=${api_client_path} -setuidgid ${media_monitor_user} python -u ${media_monitor_path}${media_monitor_script} + +# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr +python -u ${media_monitor_path}${media_monitor_script} + # EOF diff --git a/python_apps/media-monitor/airtime-media-monitor-start b/python_apps/media-monitor/airtime-media-monitor-start deleted file mode 100755 index 084b2b1ad..000000000 --- a/python_apps/media-monitor/airtime-media-monitor-start +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys - -if os.geteuid() != 0: - print "Please run this as root." - sys.exit(1) - -try: - print "Starting daemontool script recorder" - os.system("svc -u /etc/service/recorder") - -except Exception, e: - print "exception:" + str(e) diff --git a/python_apps/media-monitor/airtime-media-monitor-stop b/python_apps/media-monitor/airtime-media-monitor-stop deleted file mode 100755 index 735464dd8..000000000 --- a/python_apps/media-monitor/airtime-media-monitor-stop +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -import subprocess - -if os.geteuid() != 0: - print "Please run this as root." - sys.exit(1) - -try: - print "Stopping daemontool script recorder" - - p1 = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE) - p2 = subprocess.Popen(["awk", "/recorder.py/ && !/awk/ {print $2}"], stdin=p1.stdout, stdout=subprocess.PIPE) - recorder_pid = p2.communicate()[0].strip(" \n\r\t") - if (len(recorder_pid) > 0): - os.system("svc -d /etc/service/recorder 1>/dev/null 2>&1") - os.system("svc -d /etc/service/recorder/log 1>/dev/null 2>&1") - os.system("kill -2 %s" % recorder_pid) - print "Shutting down process id %s" % recorder_pid - print "Success." - else: - print "Not Running." - -except Exception, e: - print "exception:" + str(e) diff --git a/python_apps/media-monitor/install/media-monitor-daemontools-logger.sh b/python_apps/media-monitor/install/media-monitor-daemontools-logger.sh deleted file mode 100755 index 6819f837d..000000000 --- a/python_apps/media-monitor/install/media-monitor-daemontools-logger.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec setuidgid pypo multilog t /var/log/airtime/media-monitor/main diff --git a/python_apps/media-monitor/install/media-monitor-install.py b/python_apps/media-monitor/install/media-monitor-install.py index 8f3fb804e..fa698daed 100755 --- a/python_apps/media-monitor/install/media-monitor-install.py +++ b/python_apps/media-monitor/install/media-monitor-install.py @@ -91,34 +91,13 @@ try: os.system("chown -R pypo:pypo "+config["bin_dir"]) print "Creating symbolic links" - os.system("rm -f /usr/bin/airtime-media-monitor-start") - os.system("ln -s "+config["bin_dir"]+"/airtime-media-monitor-start /usr/bin/") - os.system("rm -f /usr/bin/airtime-media-monitor-stop") - os.system("ln -s "+config["bin_dir"]+"/airtime-media-monitor-stop /usr/bin/") - - print "Installing recorder daemon" - create_path("/etc/service/media-monitor") - create_path("/etc/service/media-monitor/log") - shutil.copy("%s/media-monitor-daemontools.sh"%current_script_dir, "/etc/service/media-monitor/run") - shutil.copy("%s/media-monitor-daemontools-logger.sh"%current_script_dir, "/etc/service/media-monitor/log/run") - os.system("chmod -R 755 /etc/service/media-monitor") - os.system("chown -R pypo:pypo /etc/service/media-monitor") + os.system("rm -f /usr/bin/airtime-media-monitor") + os.system("ln -s "+config["bin_dir"]+"/airtime-media-monitor /usr/bin/") print "Waiting for processes to start..." - time.sleep(5) - os.system("python /usr/bin/airtime-media-monitor-start") - time.sleep(2) + p = Popen("/etc/init.d/airtime-media-monitor start", shell=True) + sts = os.waitpid(p.pid, 0)[1] - found = True - - p = Popen('svstat /etc/service/media-monitor', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) - output = p.stdout.read() - if (output.find("unable to open supervise/ok: file does not exist") >= 0): - found = False - print output - - if not found: - print "Media monitor install has completed, but daemontools is not running, please make sure you have it installed and then reboot." except Exception, e: print "exception:" + str(e) sys.exit(1) diff --git a/python_apps/media-monitor/logging.cfg b/python_apps/media-monitor/logging.cfg index 251fce8d7..c0a43564c 100644 --- a/python_apps/media-monitor/logging.cfg +++ b/python_apps/media-monitor/logging.cfg @@ -2,20 +2,20 @@ keys=root [handlers] -keys=consoleHandler +keys=fileOutHandler [formatters] keys=simpleFormatter [logger_root] level=DEBUG -handlers=consoleHandler +handlers=fileOutHandler -[handler_consoleHandler] -class=StreamHandler +[handler_fileOutHandler] +class=logging.handlers.RotatingFileHandler level=DEBUG formatter=simpleFormatter -args=(sys.stdout,) +args=("/var/log/airtime/media-monitor/media-monitor.log", 'a', 1000000, 5,) [formatter_simpleFormatter] format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s diff --git a/python_apps/pypo/install/pypo-daemontools-liquidsoap.sh b/python_apps/pypo/airtime-liquidsoap similarity index 100% rename from python_apps/pypo/install/pypo-daemontools-liquidsoap.sh rename to python_apps/pypo/airtime-liquidsoap diff --git a/python_apps/pypo/airtime-pypo b/python_apps/pypo/airtime-playout similarity index 100% rename from python_apps/pypo/airtime-pypo rename to python_apps/pypo/airtime-playout diff --git a/python_apps/pypo/airtime-pypo-init-d b/python_apps/pypo/airtime-playout-init-d similarity index 97% rename from python_apps/pypo/airtime-pypo-init-d rename to python_apps/pypo/airtime-playout-init-d index db6fd1510..940ff8781 100755 --- a/python_apps/pypo/airtime-pypo-init-d +++ b/python_apps/pypo/airtime-playout-init-d @@ -4,7 +4,7 @@ USERID=pypo GROUPID=pypo NAME=Airtime -DAEMON=/usr/bin/airtime-pypo +DAEMON=/usr/bin/airtime-playout PIDFILE=/var/run/airtime.pid start () { diff --git a/python_apps/pypo/install/pypo-daemontools-logger.sh b/python_apps/pypo/install/pypo-daemontools-logger.sh deleted file mode 100755 index 249bfd78b..000000000 --- a/python_apps/pypo/install/pypo-daemontools-logger.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec setuidgid pypo multilog t /var/log/airtime/pypo/main diff --git a/python_apps/pypo/install/pypo-daemontools.sh b/python_apps/pypo/install/pypo-daemontools.sh deleted file mode 100755 index 9ad0dd683..000000000 --- a/python_apps/pypo/install/pypo-daemontools.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -pypo_user="pypo" -export HOME="/var/tmp/airtime/pypo/" -# Location of pypo_cli.py Python script -pypo_path="/usr/lib/airtime/pypo/bin/" -api_client_path="/usr/lib/airtime/pypo/" -pypo_script="pypo-cli.py" -echo "*** Daemontools: starting daemon" -cd ${pypo_path} -exec 2>&1 - -PYTHONPATH=${api_client_path}:$PYTHONPATH -export PYTHONPATH - -# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr -exec python -u ${pypo_path}${pypo_script} -# EOF diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index 4d2aaa27c..fe75d0860 100755 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -136,46 +136,18 @@ try: os.system("chown -R pypo:pypo "+config["bin_dir"]) os.system("chown -R pypo:pypo "+config["cache_base_dir"]) - """ print "Creating symbolic links" - os.system("rm -f /usr/bin/airtime-playout-start") - os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout-start /usr/bin/") - os.system("rm -f /usr/bin/airtime-playout-stop") - os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout-stop /usr/bin/") - """ - - print "Creating symbolic links" - os.system("rm -f /usr/bin/airtime-pypo") - os.system("ln -s "+config["bin_dir"]+"/bin/airtime-pypo /usr/bin/") + os.system("rm -f /usr/bin/airtime-playout") + os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout /usr/bin/") + os.system("rm -f /usr/bin/airtime-liquidsoap") + os.system("ln -s "+config["bin_dir"]+"/bin/airtime-liquidsoap /usr/bin/") print "Installing pypo daemon" - shutil.copy(config["bin_dir"]+"/bin/airtime-pypo-init-d", "/etc/init.d/airtime-pypo") + shutil.copy(config["bin_dir"]+"/bin/airtime-playout-init-d", "/etc/init.d/airtime-playout") - - """ - create_path("/etc/service/pypo") - create_path("/etc/service/pypo/log") - shutil.copy("%s/pypo-daemontools.sh"%current_script_dir, "/etc/service/pypo/run") - shutil.copy("%s/pypo-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo/log/run") - os.system("chmod -R 755 /etc/service/pypo") - os.system("chown -R pypo:pypo /etc/service/pypo") - """ - - - """ - print "Installing liquidsoap daemon" - create_path("/etc/service/pypo-liquidsoap") - create_path("/etc/service/pypo-liquidsoap/log") - shutil.copy("%s/pypo-daemontools-liquidsoap.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/run") - shutil.copy("%s/pypo-liquidsoap-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/log/run") - os.system("chmod -R 755 /etc/service/pypo-liquidsoap") - os.system("chown -R pypo:pypo /etc/service/pypo-liquidsoap") - """ - print "Waiting for processes to start..." - - p = Popen("/etc/init.d/airtime-pypo start", shell=True) + p = Popen("/etc/init.d/airtime-playout start", shell=True) sts = os.waitpid(p.pid, 0)[1] except Exception, e: diff --git a/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh b/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh deleted file mode 100644 index 98ac88c3b..000000000 --- a/python_apps/pypo/install/pypo-liquidsoap-daemontools-logger.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec setuidgid pypo multilog t /var/log/airtime/pypo-liquidsoap/main diff --git a/python_apps/pypo/logging.cfg b/python_apps/pypo/logging.cfg index 7b679d40c..234a094f0 100644 --- a/python_apps/pypo/logging.cfg +++ b/python_apps/pypo/logging.cfg @@ -1,33 +1,39 @@ [loggers] -keys=root,fetch,push +keys=root,fetch,push,cue_file [handlers] -keys=consoleHandler +keys=fileOutHandler [formatters] keys=simpleFormatter [logger_root] level=DEBUG -handlers=consoleHandler +handlers=fileOutHandler [logger_fetch] level=DEBUG -handlers=consoleHandler +handlers=fileOutHandler qualname=fetch propagate=0 [logger_push] level=DEBUG -handlers=consoleHandler +handlers=fileOutHandler qualname=push propagate=0 -[handler_consoleHandler] -class=StreamHandler +[logger_cue_file] +level=DEBUG +handlers=fileOutHandler +qualname=push +propagate=0 + +[handler_fileOutHandler] +class=logging.handlers.RotatingFileHandler level=DEBUG formatter=simpleFormatter -args=(sys.stdout,) +args=("/var/log/airtime/pypo/pypo.log", 'a', 1000000, 5,) [formatter_simpleFormatter] format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s diff --git a/python_apps/pypo/pypo-cli.py b/python_apps/pypo/pypo-cli.py index 73d5fd9ec..b05bf34c2 100755 --- a/python_apps/pypo/pypo-cli.py +++ b/python_apps/pypo/pypo-cli.py @@ -11,6 +11,7 @@ import os import signal import logging import logging.config +import logging.handlers from Queue import Queue from pypopush import PypoPush diff --git a/python_apps/pypo/pypo-log.sh b/python_apps/pypo/pypo-log.sh deleted file mode 100755 index 0e3c91275..000000000 --- a/python_apps/pypo/pypo-log.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -clear -echo -echo "##############################" -echo "# STARTING PYPO MULTI-LOG #" -echo "##############################" -sleep 1 -clear - -# split -multitail -s 2 /var/log/pypo/debug.log \ -/var/log/pypo-push/log/main/current \ -/var/log/pypo-fetch/log/main/current \ -/var/log/pypo-liquidsoap/log/main/current diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 573770694..c2b895bd5 100755 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -3,6 +3,7 @@ import sys import time import logging import logging.config +import logging.handlers import pickle import telnetlib import calendar @@ -15,6 +16,7 @@ from util import CueFile from configobj import ConfigObj + # configure logging logging.config.fileConfig("logging.cfg") @@ -130,14 +132,19 @@ class PypoPush(Thread): else: pass #logger.debug('Empty schedule') - - if not currently_on_air and self.liquidsoap_state_play: - logger.debug('Notifying Liquidsoap to stop playback.') - tn = telnetlib.Telnet(LS_HOST, LS_PORT) - tn.write('source.skip\n') - tn.write('exit\n') - tn.read_all() + + try: + if not currently_on_air and self.liquidsoap_state_play: + logger.debug('Notifying Liquidsoap to stop playback.') + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + tn.write('source.skip\n') + tn.write('exit\n') + tn.read_all() + self.liquidsoap_state_play = False + except Exception, e: self.liquidsoap_state_play = False + logger.debug('Could not connect to liquidsoap') + def push_liquidsoap(self, pkey, schedule, playlists): logger = logging.getLogger('push') diff --git a/python_apps/pypo/util/cue_file.py b/python_apps/pypo/util/cue_file.py index 8b3a158be..7d752dd80 100755 --- a/python_apps/pypo/util/cue_file.py +++ b/python_apps/pypo/util/cue_file.py @@ -21,7 +21,7 @@ class CueFile(): def cue(self, src, dst, cue_in, cue_out): - logger = logging.getLogger("cue_file.cue") + logger = logging.getLogger("cue_file") logger.debug("cue file: %s %s %s %s", src, dst, cue_in, cue_out) if src.lower().endswith('.mp3'): diff --git a/python_apps/show-recorder/install/recorder-daemontools.sh b/python_apps/show-recorder/airtime-show-recorder similarity index 100% rename from python_apps/show-recorder/install/recorder-daemontools.sh rename to python_apps/show-recorder/airtime-show-recorder diff --git a/python_apps/show-recorder/airtime-show-recorder-start b/python_apps/show-recorder/airtime-show-recorder-start deleted file mode 100755 index 084b2b1ad..000000000 --- a/python_apps/show-recorder/airtime-show-recorder-start +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys - -if os.geteuid() != 0: - print "Please run this as root." - sys.exit(1) - -try: - print "Starting daemontool script recorder" - os.system("svc -u /etc/service/recorder") - -except Exception, e: - print "exception:" + str(e) diff --git a/python_apps/show-recorder/airtime-show-recorder-stop b/python_apps/show-recorder/airtime-show-recorder-stop deleted file mode 100755 index e9a529bfd..000000000 --- a/python_apps/show-recorder/airtime-show-recorder-stop +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -import subprocess - -if os.geteuid() != 0: - print "Please run this as root." - sys.exit(1) - -try: - print "Stopping daemontool script recorder..." - - p1 = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE) - p2 = subprocess.Popen(["awk", "/recorder.py/ && !/awk/ {print $2}"], stdin=p1.stdout, stdout=subprocess.PIPE) - recorder_pid = p2.communicate()[0].strip(" \n\r\t") - if (len(recorder_pid) > 0): - os.system("svc -d /etc/service/recorder 1>/dev/null 2>&1") - os.system("svc -d /etc/service/recorder/log 1>/dev/null 2>&1") - - pids = recorder_pid.split("\n") - for pid in pids: - os.system("kill -2 %s" % pid) - print "Shutting down process id %s" % pid - print "Success." - else: - print "Not Running." - -except Exception, e: - print "exception:" + str(e) diff --git a/python_apps/show-recorder/install/recorder-daemontools-logger.sh b/python_apps/show-recorder/install/recorder-daemontools-logger.sh deleted file mode 100755 index 3510acf44..000000000 --- a/python_apps/show-recorder/install/recorder-daemontools-logger.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec setuidgid pypo multilog t /var/log/airtime/show-recorder/main diff --git a/python_apps/show-recorder/install/recorder-install.py b/python_apps/show-recorder/install/recorder-install.py index f5169a9c9..0b49e9547 100755 --- a/python_apps/show-recorder/install/recorder-install.py +++ b/python_apps/show-recorder/install/recorder-install.py @@ -94,34 +94,13 @@ try: os.system("chown -R pypo:pypo "+config["bin_dir"]) print "Creating symbolic links" - os.system("rm -f /usr/bin/airtime-show-recorder-start") - os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder-start /usr/bin/") - os.system("rm -f /usr/bin/airtime-show-recorder-stop") - os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder-stop /usr/bin/") - - print "Installing recorder daemon" - create_path("/etc/service/recorder") - create_path("/etc/service/recorder/log") - shutil.copy("%s/recorder-daemontools.sh"%current_script_dir, "/etc/service/recorder/run") - shutil.copy("%s/recorder-daemontools-logger.sh"%current_script_dir, "/etc/service/recorder/log/run") - os.system("chmod -R 755 /etc/service/recorder") - os.system("chown -R pypo:pypo /etc/service/recorder") - + os.system("rm -f /usr/bin/airtime-show-recorder") + os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder /usr/bin/") + print "Waiting for processes to start..." - time.sleep(5) - os.system("python /usr/bin/airtime-show-recorder-start") - time.sleep(2) + p = Popen("/etc/init.d/airtime-show-recorder start", shell=True) + sts = os.waitpid(p.pid, 0)[1] - found = True - - p = Popen('svstat /etc/service/recorder', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) - output = p.stdout.read() - if (output.find("unable to open supervise/ok: file does not exist") >= 0): - found = False - print output - - if not found: - print "Recorder install has completed, but daemontools is not running, please make sure you have it installed and then reboot." except Exception, e: print "exception:" + str(e) sys.exit(1) diff --git a/python_apps/show-recorder/logging.cfg b/python_apps/show-recorder/logging.cfg index 251fce8d7..766f56972 100644 --- a/python_apps/show-recorder/logging.cfg +++ b/python_apps/show-recorder/logging.cfg @@ -2,20 +2,20 @@ keys=root [handlers] -keys=consoleHandler +keys=fileOutHandler [formatters] keys=simpleFormatter [logger_root] level=DEBUG -handlers=consoleHandler +handlers=fileOutHandler -[handler_consoleHandler] -class=StreamHandler +[handler_fileOutHandler] +class=logging.handlers.RotatingFileHandler level=DEBUG formatter=simpleFormatter -args=(sys.stdout,) +args=("/var/log/airtime/show-recorder/show-recorder.log", 'a', 1000000, 5,) [formatter_simpleFormatter] format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s