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,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 ***" echo "*** Pypo Installation ***"
#python ".__DIR__."/../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 || exit $? python ../python_apps/pypo/install/pypo-install.py
echo "*** Recorder Installation ***" #echo "*** Recorder Installation ***"
#python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py || exit $? #python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py
#python ../python_apps/show-recorder/install/recorder-install.py || exit $? #python ../python_apps/show-recorder/install/recorder-install.py
airtime-check-system airtime-check-system
echo -e "\n******************************* Install Complete *******************************";

View File

@ -10,9 +10,6 @@
*/ */
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path()); 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/AirtimeIni.php');
require_once(dirname(__FILE__).'/include/AirtimeInstall.php'); require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
@ -126,19 +123,7 @@ AirtimeInstall::CreateSymlinksToUtils();
AirtimeInstall::CreateZendPhpLogFile(); 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 //wait for 1.9.0 release
//echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL; //echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL;
//system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py"); //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;

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
media_monitor_user="pypo"
# Location of pypo_cli.py Python script # Location of pypo_cli.py Python script
media_monitor_path="/usr/lib/airtime/media-monitor/" media_monitor_path="/usr/lib/airtime/media-monitor/"
@ -8,10 +7,11 @@ media_monitor_script="MediaMonitor.py"
api_client_path="/usr/lib/airtime/pypo/" api_client_path="/usr/lib/airtime/pypo/"
cd ${media_monitor_path} cd ${media_monitor_path}
echo "*** Daemontools: starting daemon"
exec 2>&1 exec 2>&1
# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr
export PYTHONPATH=${api_client_path} 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 # 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"]) os.system("chown -R pypo:pypo "+config["bin_dir"])
print "Creating symbolic links" print "Creating symbolic links"
os.system("rm -f /usr/bin/airtime-media-monitor-start") os.system("rm -f /usr/bin/airtime-media-monitor")
os.system("ln -s "+config["bin_dir"]+"/airtime-media-monitor-start /usr/bin/") os.system("ln -s "+config["bin_dir"]+"/airtime-media-monitor /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")
print "Waiting for processes to start..." print "Waiting for processes to start..."
time.sleep(5) p = Popen("/etc/init.d/airtime-media-monitor start", shell=True)
os.system("python /usr/bin/airtime-media-monitor-start") sts = os.waitpid(p.pid, 0)[1]
time.sleep(2)
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: except Exception, e:
print "exception:" + str(e) print "exception:" + str(e)
sys.exit(1) sys.exit(1)

View File

@ -2,20 +2,20 @@
keys=root keys=root
[handlers] [handlers]
keys=consoleHandler keys=fileOutHandler
[formatters] [formatters]
keys=simpleFormatter keys=simpleFormatter
[logger_root] [logger_root]
level=DEBUG level=DEBUG
handlers=consoleHandler handlers=fileOutHandler
[handler_consoleHandler] [handler_fileOutHandler]
class=StreamHandler class=logging.handlers.RotatingFileHandler
level=DEBUG level=DEBUG
formatter=simpleFormatter formatter=simpleFormatter
args=(sys.stdout,) args=("/var/log/airtime/media-monitor/media-monitor.log", 'a', 1000000, 5,)
[formatter_simpleFormatter] [formatter_simpleFormatter]
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s

View File

@ -4,7 +4,7 @@ USERID=pypo
GROUPID=pypo GROUPID=pypo
NAME=Airtime NAME=Airtime
DAEMON=/usr/bin/airtime-pypo DAEMON=/usr/bin/airtime-playout
PIDFILE=/var/run/airtime.pid PIDFILE=/var/run/airtime.pid
start () { start () {

View File

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

View File

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

View File

@ -136,46 +136,18 @@ try:
os.system("chown -R pypo:pypo "+config["bin_dir"]) os.system("chown -R pypo:pypo "+config["bin_dir"])
os.system("chown -R pypo:pypo "+config["cache_base_dir"]) os.system("chown -R pypo:pypo "+config["cache_base_dir"])
"""
print "Creating symbolic links" print "Creating symbolic links"
os.system("rm -f /usr/bin/airtime-playout-start") os.system("rm -f /usr/bin/airtime-playout")
os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout-start /usr/bin/") os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout /usr/bin/")
os.system("rm -f /usr/bin/airtime-playout-stop") os.system("rm -f /usr/bin/airtime-liquidsoap")
os.system("ln -s "+config["bin_dir"]+"/bin/airtime-playout-stop /usr/bin/") os.system("ln -s "+config["bin_dir"]+"/bin/airtime-liquidsoap /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/")
print "Installing pypo daemon" 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..." print "Waiting for processes to start..."
p = Popen("/etc/init.d/airtime-playout start", shell=True)
p = Popen("/etc/init.d/airtime-pypo start", shell=True)
sts = os.waitpid(p.pid, 0)[1] sts = os.waitpid(p.pid, 0)[1]
except Exception, e: except Exception, e:

View File

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

View File

@ -1,33 +1,39 @@
[loggers] [loggers]
keys=root,fetch,push keys=root,fetch,push,cue_file
[handlers] [handlers]
keys=consoleHandler keys=fileOutHandler
[formatters] [formatters]
keys=simpleFormatter keys=simpleFormatter
[logger_root] [logger_root]
level=DEBUG level=DEBUG
handlers=consoleHandler handlers=fileOutHandler
[logger_fetch] [logger_fetch]
level=DEBUG level=DEBUG
handlers=consoleHandler handlers=fileOutHandler
qualname=fetch qualname=fetch
propagate=0 propagate=0
[logger_push] [logger_push]
level=DEBUG level=DEBUG
handlers=consoleHandler handlers=fileOutHandler
qualname=push qualname=push
propagate=0 propagate=0
[handler_consoleHandler] [logger_cue_file]
class=StreamHandler level=DEBUG
handlers=fileOutHandler
qualname=push
propagate=0
[handler_fileOutHandler]
class=logging.handlers.RotatingFileHandler
level=DEBUG level=DEBUG
formatter=simpleFormatter formatter=simpleFormatter
args=(sys.stdout,) args=("/var/log/airtime/pypo/pypo.log", 'a', 1000000, 5,)
[formatter_simpleFormatter] [formatter_simpleFormatter]
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s

View File

@ -11,6 +11,7 @@ import os
import signal import signal
import logging import logging
import logging.config import logging.config
import logging.handlers
from Queue import Queue from Queue import Queue
from pypopush import PypoPush from pypopush import PypoPush

View File

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

View File

@ -3,6 +3,7 @@ import sys
import time import time
import logging import logging
import logging.config import logging.config
import logging.handlers
import pickle import pickle
import telnetlib import telnetlib
import calendar import calendar
@ -15,6 +16,7 @@ from util import CueFile
from configobj import ConfigObj from configobj import ConfigObj
# configure logging # configure logging
logging.config.fileConfig("logging.cfg") logging.config.fileConfig("logging.cfg")
@ -130,14 +132,19 @@ class PypoPush(Thread):
else: else:
pass pass
#logger.debug('Empty schedule') #logger.debug('Empty schedule')
if not currently_on_air and self.liquidsoap_state_play: try:
logger.debug('Notifying Liquidsoap to stop playback.') if not currently_on_air and self.liquidsoap_state_play:
tn = telnetlib.Telnet(LS_HOST, LS_PORT) logger.debug('Notifying Liquidsoap to stop playback.')
tn.write('source.skip\n') tn = telnetlib.Telnet(LS_HOST, LS_PORT)
tn.write('exit\n') tn.write('source.skip\n')
tn.read_all() tn.write('exit\n')
tn.read_all()
self.liquidsoap_state_play = False
except Exception, e:
self.liquidsoap_state_play = False self.liquidsoap_state_play = False
logger.debug('Could not connect to liquidsoap')
def push_liquidsoap(self, pkey, schedule, playlists): def push_liquidsoap(self, pkey, schedule, playlists):
logger = logging.getLogger('push') logger = logging.getLogger('push')

View File

@ -21,7 +21,7 @@ class CueFile():
def cue(self, src, dst, cue_in, cue_out): 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) logger.debug("cue file: %s %s %s %s", src, dst, cue_in, cue_out)
if src.lower().endswith('.mp3'): if src.lower().endswith('.mp3'):

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

View File

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

View File

@ -94,34 +94,13 @@ try:
os.system("chown -R pypo:pypo "+config["bin_dir"]) os.system("chown -R pypo:pypo "+config["bin_dir"])
print "Creating symbolic links" print "Creating symbolic links"
os.system("rm -f /usr/bin/airtime-show-recorder-start") os.system("rm -f /usr/bin/airtime-show-recorder")
os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder-start /usr/bin/") os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder /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")
print "Waiting for processes to start..." print "Waiting for processes to start..."
time.sleep(5) p = Popen("/etc/init.d/airtime-show-recorder start", shell=True)
os.system("python /usr/bin/airtime-show-recorder-start") sts = os.waitpid(p.pid, 0)[1]
time.sleep(2)
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: except Exception, e:
print "exception:" + str(e) print "exception:" + str(e)
sys.exit(1) sys.exit(1)

View File

@ -2,20 +2,20 @@
keys=root keys=root
[handlers] [handlers]
keys=consoleHandler keys=fileOutHandler
[formatters] [formatters]
keys=simpleFormatter keys=simpleFormatter
[logger_root] [logger_root]
level=DEBUG level=DEBUG
handlers=consoleHandler handlers=fileOutHandler
[handler_consoleHandler] [handler_fileOutHandler]
class=StreamHandler class=logging.handlers.RotatingFileHandler
level=DEBUG level=DEBUG
formatter=simpleFormatter formatter=simpleFormatter
args=(sys.stdout,) args=("/var/log/airtime/show-recorder/show-recorder.log", 'a', 1000000, 5,)
[formatter_simpleFormatter] [formatter_simpleFormatter]
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s