From 84bcb54ff2bf7e1155d4975caa37d5a187119a31 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 15 Apr 2013 18:32:13 -0700 Subject: [PATCH 1/3] Adding work to fabfile. Changing deploy to deploy_code. --- fabfile.py | 13 +++++++-- utils/zgrep.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100755 utils/zgrep.py diff --git a/fabfile.py b/fabfile.py index 3ca123fdc..87a624498 100644 --- a/fabfile.py +++ b/fabfile.py @@ -65,6 +65,10 @@ def server(): def app(): server() env.roles = ['app'] + +def work(): + server() + env.roles = ['work'] def dev(): server() @@ -117,10 +121,13 @@ def post_deploy(): @parallel def deploy(fast=False): - deploy_code(copy_assets=True, fast=fast) + deploy_code(copy_assets=False, fast=fast) -def deploy_full(): - deploy_code(copy_assets=True, full=True) +def deploy_web(fast=False): + deploy_code(copy_assets=True, fast=fast, full=False) + +def deploy_full(fast=False): + deploy_code(copy_assets=True, fast=fast, full=True) @parallel def deploy_code(copy_assets=False, full=False, fast=False): diff --git a/utils/zgrep.py b/utils/zgrep.py new file mode 100755 index 000000000..7533e9dcb --- /dev/null +++ b/utils/zgrep.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +from optparse import OptionParser +import os +import select +import subprocess +import sys +import yaml + + +IGNORE_HOSTS = [ + 'push', +] + +def main(role="app", role2="dev", command=None, path=None): + streams = list() + if not path: + path = "/srv/newsblur/logs/newsblur.log" + if not command: + command = "tail -f" + hosts_path = os.path.expanduser(os.path.join('../secrets-newsblur/configs/hosts.yml')) + hosts = yaml.load(open(hosts_path)) + + for r in [role, role2]: + if isinstance(hosts[r], dict): + hosts[r] = ["%s:%s" % (hosts[r][k][-1], k) for k in hosts[r].keys()] + + for hostname in set(hosts[role] + hosts[role2]): + if any(h in hostname for h in IGNORE_HOSTS): continue + if ':' in hostname: + hostname, address = hostname.split(':', 1) + else: + address = hostname + if 'ec2' in hostname: + s = subprocess.Popen(["ssh", "-i", os.path.expanduser("~/.ec2/sclay.pem"), + address, "%s %s" % (command, path)], stdout=subprocess.PIPE) + else: + s = subprocess.Popen(["ssh", address, "%s %s" % (command, path)], stdout=subprocess.PIPE) + s.name = hostname + streams.append(s) + + try: + i = 0 + while True: + i += 1 + r, _, _ = select.select( + [stream.stdout.fileno() for stream in streams], [], []) + for fileno in r: + for stream in streams: + if stream.stdout.fileno() != fileno: + continue + data = os.read(fileno, 4096) + if not data: + streams.remove(stream) + break + combination_message = "%s" % (data) + sys.stdout.write(combination_message) + break + if i > 1000: + break + except KeyboardInterrupt: + print " --- End of Logging ---" + + +if __name__ == "__main__": + parser = OptionParser() + parser.add_option("-f", "--find", dest="find") + parser.add_option("-p", "--path", dest="path") + (options, args) = parser.parse_args() + + path = options.path + find = options.find + command = "zgrep \"%s\"" % find + main(role="app", role2="dev", command=command, path=path) \ No newline at end of file From 959fb172f1091949005a27bd1384bdb91ba13270 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 15 Apr 2013 18:51:26 -0700 Subject: [PATCH 2/3] Adding meta refresh to maintenance page. --- templates/maintenance_off.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/maintenance_off.html b/templates/maintenance_off.html index 896bc1ec5..80daff08f 100644 --- a/templates/maintenance_off.html +++ b/templates/maintenance_off.html @@ -7,7 +7,9 @@ - + + +