Fill memcached caches synchronously before restarting the server

(imported from commit a45fa845e94a1fc6e96a1aafca31e9a6fc2b7526)
This commit is contained in:
Zev Benjamin 2013-05-30 15:05:34 -04:00 committed by Tim Abbott
parent 2f7f0da27f
commit 300e57fcbd
2 changed files with 4 additions and 14 deletions

View File

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

View File

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