Skip to content

Commit

Permalink
Merge pull request #3 from launchdarkly/jkodumal/ch3665/ld-relay-shou…
Browse files Browse the repository at this point in the history
…ld-have-a-default-port

Add a default port, and check if no environments are specified.
  • Loading branch information
jkodumal authored May 25, 2017
2 parents 63d5f94 + b83b44f commit d3ca2b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Here's an example configuration file that synchronizes four environments across
[environment "Shopnify Project Test"]
apiKey = "SHOPNIFY_TEST_API_KEY"

Your configuration file must include at least one environment.

Relay proxy mode
----------------

Expand Down
11 changes: 11 additions & 0 deletions ld-relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

const (
defaultRedisLocalTtlMs = 30000
defaultPort = 8030
)

var (
Expand Down Expand Up @@ -92,6 +93,16 @@ func main() {
c.Redis.LocalTtl = &localTtl
}

if c.Main.Port == 0 {
Info.Printf("No port specified in configuration file. Using default port %d.", defaultPort)
c.Main.Port = defaultPort
}

if len(c.Environment) == 0 {
Error.Println("You must specify at least one environment in your configuration file. Exiting.")
os.Exit(1)
}

publisher := eventsource.NewServer()
publisher.Gzip = false
publisher.AllowCORS = true
Expand Down

0 comments on commit d3ca2b0

Please sign in to comment.