Yank out clientapi config options to env vars for now (#77)

This commit is contained in:
Kegsay 2017-04-20 17:15:34 +01:00 committed by GitHub
parent 2fadb9e409
commit cb5081b332

View file

@ -4,6 +4,7 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"golang.org/x/crypto/ed25519" "golang.org/x/crypto/ed25519"
@ -31,15 +32,31 @@ func setupLogging(logDir string) {
)) ))
} }
var (
kafkaURIs = strings.Split(os.Getenv("KAFKA_URIS"), ",")
bindAddr = os.Getenv("BIND_ADDRESS")
logDir = os.Getenv("LOG_DIR")
roomserverURL = os.Getenv("ROOMSERVER_URL")
clientAPIOutputTopic = os.Getenv("CLIENTAPI_OUTPUT_TOPIC")
)
func main() { func main() {
bindAddr := os.Getenv("BIND_ADDRESS")
if bindAddr == "" { if bindAddr == "" {
log.Panic("No BIND_ADDRESS environment variable found.") log.Panic("No BIND_ADDRESS environment variable found.")
} }
logDir := os.Getenv("LOG_DIR")
if logDir != "" { if logDir != "" {
setupLogging(logDir) setupLogging(logDir)
} }
if len(kafkaURIs) == 0 {
// the kafka default is :9092
kafkaURIs = []string{"localhost:9092"}
}
if roomserverURL == "" {
log.Panic("No ROOMSERVER_URL environment variable found.")
}
if clientAPIOutputTopic == "" {
log.Panic("No CLIENTAPI_OUTPUT_TOPIC environment variable found. This should match the roomserver input topic.")
}
// TODO: Rather than generating a new key on every startup, we should be // TODO: Rather than generating a new key on every startup, we should be
// reading a PEM formatted file instead. // reading a PEM formatted file instead.
@ -52,9 +69,9 @@ func main() {
ServerName: "localhost", ServerName: "localhost",
KeyID: "ed25519:something", KeyID: "ed25519:something",
PrivateKey: privKey, PrivateKey: privKey,
KafkaProducerURIs: []string{"localhost:9092"}, KafkaProducerURIs: kafkaURIs,
ClientAPIOutputTopic: "roomserverInput", ClientAPIOutputTopic: clientAPIOutputTopic,
RoomserverURL: "http://localhost:7777", RoomserverURL: roomserverURL,
} }
log.Info("Starting clientapi") log.Info("Starting clientapi")