Skip to content

Instantly share code, notes, and snippets.

@yaronp68
Created January 31, 2012 12:59
Show Gist options
  • Select an option

  • Save yaronp68/1710373 to your computer and use it in GitHub Desktop.

Select an option

Save yaronp68/1710373 to your computer and use it in GitHub Desktop.
Apache Load Balancer Custom Commands
customCommands ([
"add-node" : { node, instanceID ->
def proxyConfigFile = new File(context.serviceDirectory + "/install/conf/extra/httpd-proxy-balancer.conf")
def config = proxyConfigFile.text
def modifiedConfig = config.replace("# Generated code - DO NOT MODIFY", "# Generated code - DO NOT MODIFY" + System.getProperty("line.separator") + "BalancerMember " + node + " route=" + instanceID)
proxyConfigFile.text = modifiedConfig
ServiceUtils.killProcess(context.externalProcessId)
},
"remove-node" : { node, instanceID ->
def proxyConfigFile = new File(context.serviceDirectory + "/install/conf/extra/httpd-proxy-balancer.conf")
def config = proxyConfigFile.text
def modifiedConfig = config.replace("BalancerMember " + node + " route=" + instanceID, "")
proxyConfigFile.text = modifiedConfig
ServiceUtils.killProcess(context.externalProcessId)
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment