From e037419c2b943de876b90b2a6772ff414ac6ca8f Mon Sep 17 00:00:00 2001 From: Brian Ip Date: Mon, 27 Jul 2015 16:45:55 -0700 Subject: [PATCH] make agent api port configurable --- conf/orchestrator.conf.json.sample | 1 + go/app/http.go | 15 ++++++++------- go/config/config.go | 5 ++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/conf/orchestrator.conf.json.sample b/conf/orchestrator.conf.json.sample index 91e6dda4..466c6be4 100644 --- a/conf/orchestrator.conf.json.sample +++ b/conf/orchestrator.conf.json.sample @@ -1,6 +1,7 @@ { "Debug": true, "ListenAddress": ":3000", + "AgentsServerPort": ":3001", "MySQLTopologyUser": "msandbox", "MySQLTopologyPassword": "msandbox", "MySQLTopologyCredentialsConfigFile": "", diff --git a/go/app/http.go b/go/app/http.go index 843cc935..2a784f04 100644 --- a/go/app/http.go +++ b/go/app/http.go @@ -18,6 +18,12 @@ package app import ( + nethttp "net/http" + "os" + "os/signal" + "strings" + "syscall" + "github.com/go-martini/martini" "github.com/martini-contrib/auth" "github.com/martini-contrib/gzip" @@ -27,11 +33,6 @@ import ( "github.com/outbrain/orchestrator/go/http" "github.com/outbrain/orchestrator/go/inst" "github.com/outbrain/orchestrator/go/logic" - nethttp "net/http" - "os" - "os/signal" - "strings" - "syscall" ) // acceptSignals registers for OS signals @@ -138,11 +139,11 @@ func agentsHttp() { // Serve if config.Config.AgentsUseSSL { log.Info("Serving via SSL") - err := nethttp.ListenAndServeTLS(":3001", config.Config.SSLCertFile, config.Config.SSLPrivateKeyFile, m) + err := nethttp.ListenAndServeTLS(config.Config.AgentsServerPort, config.Config.SSLCertFile, config.Config.SSLPrivateKeyFile, m) if err != nil { log.Fatale(err) } } else { - nethttp.ListenAndServe(":3001", m) + nethttp.ListenAndServe(config.Config.AgentsServerPort, m) } } diff --git a/go/config/config.go b/go/config/config.go index a23e6642..e25bebbd 100644 --- a/go/config/config.go +++ b/go/config/config.go @@ -17,10 +17,11 @@ package config import ( - "code.google.com/p/gcfg" "encoding/json" "os" + "code.google.com/p/gcfg" + "github.com/outbrain/golib/log" ) @@ -30,6 +31,7 @@ import ( type Configuration struct { Debug bool // set debug mode (similar to --debug option) ListenAddress string + AgentsServerPort string // port orchestrator agents talk back to MySQLTopologyUser string MySQLTopologyPassword string // my.cnf style configuration file from where to pick credentials. Expecting `user`, `password` under `[client]` section MySQLTopologyCredentialsConfigFile string @@ -114,6 +116,7 @@ func NewConfiguration() *Configuration { return &Configuration{ Debug: false, ListenAddress: ":3000", + AgentsServerPort: ":3001", MySQLOrchestratorPort: 3306, MySQLTopologyMaxPoolConnections: 3, MySQLConnectTimeoutSeconds: 5,