Skip to content

Instantly share code, notes, and snippets.

@MWers
Created November 8, 2013 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MWers/7377630 to your computer and use it in GitHub Desktop.
Save MWers/7377630 to your computer and use it in GitHub Desktop.
prerender.io Varnish node generator
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