Created
November 8, 2013 21:00
-
-
Save MWers/7377630 to your computer and use it in GitHub Desktop.
prerender.io Varnish node generator
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
import socket | |
domain = "prerender.herokuapp.com" | |
TEMPLATE_NODE = ''' { | |
.backend = { | |
.host = "%s"; | |
.port = "80"; | |
} | |
.weight = 1; | |
} | |
''' | |
TEMPLATE_DIR = '''director prerender random { | |
%s | |
}''' | |
# FIXME: Make this more pythonic | |
(_, _, addr) = socket.gethostbyname_ex(domain) | |
nodes = "" | |
for i in range(len(addr)): | |
nodes = nodes + TEMPLATE_NODE % (addr[i]) | |
print TEMPLATE_DIR % nodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment