Skip to content

Instantly share code, notes, and snippets.

@y16ra
Created March 6, 2015 06:46
Show Gist options
  • Save y16ra/cc37f23dbe94ea700b42 to your computer and use it in GitHub Desktop.
Save y16ra/cc37f23dbe94ea700b42 to your computer and use it in GitHub Desktop.
nginx上のproxy cache をpurgeするスクリプト。(http://monasan.info/blog/用)
#!/usr/bin/env python
import os
import commands
# logging config
from logging import getLogger,StreamHandler,Formatter,DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
handler.setFormatter(Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.setLevel(DEBUG)
logger.addHandler(handler)
# search top page cache
cache_file_path = commands.getoutput("find /var/run/nginx-cache -type f -exec grep -l \"KEY: http://monasan.info/blog/$\" {} \;")
logger.debug("top page cache file : " + cache_file_path)
if os.path.exists(cache_file_path):
os.remove(cache_file_path)
logger.info(cache_file_path + " deleted.")
else:
logger.info("cache file not found.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment