From 16e8319e8217d5f22d92fc8e3168c09d08bb33c7 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 19 Mar 2015 00:29:20 +0700 Subject: [PATCH] Configure app and server ports --- config.example.json | 3 ++- config/config.go | 3 ++- server/server.go | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config.example.json b/config.example.json index 446d8c2..a719b92 100644 --- a/config.example.json +++ b/config.example.json @@ -1,5 +1,6 @@ { - "app_domain": "localhost", + "app_server_port": 8080, + "app_redis_port": 6379, "app_database_uri": "root@/empact?parseTime=true", "github_auth_url": "https://github.com/login/oauth/authorize", "github_access_token_url": "https://github.com/login/oauth/access_token", diff --git a/config/config.go b/config/config.go index 0cf532e..74a7d32 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,8 @@ import ( type ( Config struct { - Domain string `json:"app_domain"` + ServerPort int `json:"app_server_port"` + RedisPort int `json:"app_redis_port"` DatabaseURI string `json:"app_database_uri"` AuthURL string `json:"github_auth_url"` AccessTokenURL string `json:"github_access_token_url"` diff --git a/server/server.go b/server/server.go index 1b5db7f..311edeb 100644 --- a/server/server.go +++ b/server/server.go @@ -1,10 +1,12 @@ package server import ( + "fmt" "log" "net/http" "github.com/garyburd/redigo/redis" + "github.com/localhots/empact/config" ) const ( @@ -36,10 +38,10 @@ func init() { } func Start() { - log.Println("Starting server at http://localhost:8080") - http.ListenAndServe(":8080", nil) + log.Printf("Starting server at http://localhost:%d\n", config.C().ServerPort) + http.ListenAndServe(fmt.Sprintf(":%d", config.C().ServerPort), nil) } func dialRedis() (redis.Conn, error) { - return redis.Dial("tcp", ":6379") + return redis.Dial("tcp", fmt.Sprintf(":%d", config.C().RedisPort)) }