func main() { // Read in the configuration file settings. I think we should instead // serialize to JSON and treat this like a view. // haproxy.Transform() flag.StringVar(&flagConfigFile, "configFile", DEFAULT_CONFIG_FILE, "Path to toml file") flag.StringVar(&flagDebugMode, "debugMode", false, "Enable debug mode") flag.Parse() conf, err := LoadConfig(flagConfigFile) if err != nil { log.Fatal("Could not load configuration", err) } server := new(haproxy.Server) // We use two channels— one to send actions to the server and one to recieve // notifications from it. Create them right now. actionChan := make(chan haproxy.Action) notificationChan := make(chan haproxy.Event) // Handle signals gracefully in another goroutine go gracefulSignals(server, actionChan, notificationChan) // Start up the HAProxy Server go server.Start(notificationChan, actionChan) // Setup the ELB HTTP Handlers go elb.InitApiHandlers() // Fire up statsd goroutine if statsd is enabled. This might be better off in // a seperate binary to monitor HAProxy. if conf.Statsd.Enabled { go statsd.SendMetrics(server) } // Event loop for handling events from the HAProxy server // (right now, it only sends start/stop notifications) for _ = range notificationChan { log.Println("Received a notification") server.Socket = conf.Haproxy.Socket serverInfo := server.GetInfo() } }