From 41e43cb7079e6aad88a147c174d07bf8c5daaa49 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Mon, 26 Nov 2012 16:49:00 -0500 Subject: [PATCH] Flush memcached on every deploy This uses pylibmc, the same memcached client library we use from Django. If that becomes a problem for whatever reason, all we really need to do is send "flush_all\n" to TCP port 11211 on localhost. (imported from commit 0b9736bd31b0549b5dabd4b735706351635a9cf2) --- tools/update-deployment | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/update-deployment b/tools/update-deployment index d876fac55f..127d6507ec 100755 --- a/tools/update-deployment +++ b/tools/update-deployment @@ -2,6 +2,8 @@ import os import sys import subprocess +import pylibmc +import traceback def check_output(*popenargs, **kwargs): if 'stdout' in kwargs: @@ -31,6 +33,14 @@ if len(sys.argv) > 1: newrev = sys.argv[2] refname = sys.argv[3] +try: + if not pylibmc.Client(['127.0.0.1']).flush_all(): + print "%sflush_all returned False%s" % (WARNING, ENDC) + # There doesn't seem to be a method to close a pylibmc Client object. +except: + print "%sCould not flush cache:%s" % (WARNING, ENDC) + traceback.print_exc() + subprocess.check_call(["git", "fetch"], stdout=open('/dev/null', 'w')) subprocess.check_call(["git", "reset", "--hard", refname], stdout=open('/dev/null', 'w')) #subprocess.check_call(["python", "manage.py", "syncdb"], stdout=open('/dev/null', 'w'))