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
This commit is contained in:
martin 2011-05-31 16:05:48 -04:00
parent c05c2f1e28
commit 79e24e5af5
26 changed files with 75 additions and 269 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -1,2 +0,0 @@
#!/bin/sh
exec setuidgid pypo multilog t /var/log/airtime/media-monitor/main

View file

@ -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)

View file

@ -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