From 7a11f2aa41b84deffa1e4b5c8faf081231e121ba Mon Sep 17 00:00:00 2001 From: mkonecny Date: Wed, 19 Jan 2011 14:59:22 -0500 Subject: [PATCH] -streamlined the install script. Any previous running processes are shutdown immediately. --- pypo/install/pypo-install.py | 19 +++++++++++++------ pypo/install/pypo-start.py | 6 +++--- pypo/install/pypo-stop.py | 8 ++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/pypo/install/pypo-install.py b/pypo/install/pypo-install.py index c4391e498..9b93f81ec 100644 --- a/pypo/install/pypo-install.py +++ b/pypo/install/pypo-install.py @@ -55,6 +55,11 @@ def copy_dir(src_dir, dest_dir): shutil.copytree(src_dir, dest_dir) try: + + print "Terminating any existing pypo processes" + os.system("python ./pypo-stop.py") + time.sleep(5) + # Create users create_user("pypo") @@ -109,7 +114,6 @@ try: os.system("chown -R pypo:pypo /etc/service/pypo-push") print "Installing daemontool script pypo-liquidsoap" - os.system("svc -dx /etc/service/pypo-liquidsoap 1>/dev/null 2>&1") create_path("/etc/service/pypo-liquidsoap") create_path("/etc/service/pypo-liquidsoap/log") shutil.copy("pypo-daemontools-liquidsoap.sh", "/etc/service/pypo-liquidsoap/run") @@ -119,15 +123,15 @@ try: print "Waiting for processes to start..." time.sleep(5) - os.system("killall liquidsoap") os.system("python ./pypo-start.py") time.sleep(2) + found = True + p = Popen('svstat /etc/service/pypo-fetch', 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): - print "Install has completed, but daemontools is not running, please make sure you have it installed and then reboot." - sys.exit() + found = False print output p = Popen('svstat /etc/service/pypo-push', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) @@ -137,8 +141,11 @@ try: p = Popen('svstat /etc/service/pypo-liquidsoap', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p.stdout.read() print output - - print "Install complete." + + if not found: + print "Install has completed, but daemontools is not running, please make sure you have it installed and then reboot." + else: + print "Install complete." except Exception, e: print "exception:" + str(e) diff --git a/pypo/install/pypo-start.py b/pypo/install/pypo-start.py index 03c914e3f..f23794af1 100644 --- a/pypo/install/pypo-start.py +++ b/pypo/install/pypo-start.py @@ -10,13 +10,13 @@ if os.geteuid() != 0: try: print "Starting daemontool script pypo-fetch" - os.system("svc -t /etc/service/pypo-fetch") + os.system("svc -u /etc/service/pypo-fetch") print "Starting daemontool script pypo-push" - os.system("svc -t /etc/service/pypo-push") + os.system("svc -u /etc/service/pypo-push") print "Starting daemontool script pypo-liquidsoap" - os.system("svc -t /etc/service/pypo-liquidsoap") + os.system("svc -u /etc/service/pypo-liquidsoap") except Exception, e: print "exception:" + str(e) diff --git a/pypo/install/pypo-stop.py b/pypo/install/pypo-stop.py index 6e055b6b1..0f3ce5db5 100644 --- a/pypo/install/pypo-stop.py +++ b/pypo/install/pypo-stop.py @@ -10,13 +10,13 @@ if os.geteuid() != 0: try: print "Stopping daemontool script pypo-fetch" - os.system("svc -dx /etc/service/pypo-fetch") + os.system("svc -dx /etc/service/pypo-fetch 2>/dev/null") print "Stopping daemontool script pypo-push" - os.system("svc -dx /etc/service/pypo-push") + os.system("svc -dx /etc/service/pypo-push 2>/dev/null") print "Stopping daemontool script pypo-liquidsoap" - os.system("svc -dx /etc/service/pypo-liquidsoap") + os.system("svc -dx /etc/service/pypo-liquidsoap 2>/dev/null") except Exception, e: - print "exception:" + str(e) \ No newline at end of file + print "exception:" + str(e)