README for Rhaproxy
Rhaproxy is a gem providing a ruby interface to HAproxy TCP/HTTP Load Balancer.
To install, type ‘gem install rhaproxy’
Usage:
require 'rubygems'
require 'rhaproxy'
global = RhaproxyGlobal.new
global.daemon = true
global.maxconn = 256
defaults = RhaproxyDefaults.new
defaults.mode = "http"
defaults.timeout_connect = "5000ms"
defaults.timeout_client = "50000ms"
defaults.timeout_server = "50000ms"
frontend = RhaproxyFrontend.new
frontend.name = "http-in"
frontend.default_backend = "servers"
backend = RhaproxyBackend.new
backend.name = "servers"
backend.server = "server1 127.0.0.1:8000 maxconn 32"
config = Array.new
config.push([global.config])
config.push([defaults.config])
config.push([frontend.config])
config.push([backend.config])
haproxy_conf_file = File.new("haproxy.conf", "w+")
haproxy_conf_file.puts(config)
haproxy_conf_file.close
haproxy.conf:
global
daemon
maxconn 256
defaults
mode http
timeout client 50000ms
timeout connect 5000ms
timeout server 50000ms
frontend http-in
default_backend servers
backend servers
server server1 127.0.0.1:8000 maxconn 32