Created
March 29, 2016 00:42
-
-
Save chaozh/f81aeccd92ec0d2fb678 to your computer and use it in GitHub Desktop.
varnish缓存清理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys,os | |
varnish_adm='varnishadm' | |
try: | |
var=sys.argv[1:][0] | |
if 'http://' in var or 'HTTP://' in var: | |
domain=var.split('/')[2] | |
url=var.split(domain)[1] | |
if url == "": | |
url=sys.argv[1:][1] | |
cmd="""%s 'ban req.http.host ~ "%s" && req.url ~ "%s"'"""%(varnish_adm,domain,url) | |
print "clear:%s url:%s"%(domain,url) | |
os.system("%s"%cmd) | |
else: | |
print "input error!" | |
except: | |
print "INPUT ERROR!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment