From 300e57fcbd2807482e9faa685c60c41e27f2e635 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Thu, 30 May 2013 15:05:34 -0400 Subject: [PATCH] Fill memcached caches synchronously before restarting the server (imported from commit a45fa845e94a1fc6e96a1aafca31e9a6fc2b7526) --- tools/restart-server | 15 +++------------ .../management/commands/fill_memcached_caches.py | 3 +-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/restart-server b/tools/restart-server index d1745bb301..2fc4acf9d0 100755 --- a/tools/restart-server +++ b/tools/restart-server @@ -16,6 +16,9 @@ os.chdir("/home/humbug/humbug-deployments/current") # Send a statsd event on restarting the server subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))]) +logging.info("Filling memcached caches") +subprocess.check_call(["python", "./manage.py", "fill_memcached_caches"]) + # Restart the FastCGI and related processes via supervisorctl. We # minimize downtime by restarting Django and Tornado separately from # the other worker processes. @@ -26,17 +29,5 @@ subprocess.check_call(["supervisorctl", "restart", "humbug-tornado"]) subprocess.check_call(["supervisorctl", "start", "humbug-django"]) subprocess.check_call(["supervisorctl", "start", "humbug-workers:*"]) -logging.info("Flushing memcached") -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() - -logging.info("Refilling memcached caches") -subprocess.check_call(["python", "./manage.py", "fill_memcached_caches"]) - logging.info("Done!") print OKGREEN + "Application restarted successfully!" + ENDC diff --git a/zephyr/management/commands/fill_memcached_caches.py b/zephyr/management/commands/fill_memcached_caches.py index 15f6f20160..3480d316b1 100644 --- a/zephyr/management/commands/fill_memcached_caches.py +++ b/zephyr/management/commands/fill_memcached_caches.py @@ -16,6 +16,5 @@ class Command(BaseCommand): return fill_memcached_cache(options["cache"]) for cache in cache_fillers.keys(): - subprocess.Popen(["python", os.path.join(os.path.dirname(__file__), "../../..", "manage.py"), - "fill_memcached_caches", "--cache", cache]) + fill_memcached_cache(cache)