1
0
Fork 0

Configure app and server ports

This commit is contained in:
Gregory Eremin 2015-03-19 00:29:20 +07:00
parent ae4d1d13a2
commit 16e8319e82
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
{ {
"app_domain": "localhost", "app_server_port": 8080,
"app_redis_port": 6379,
"app_database_uri": "root@/empact?parseTime=true", "app_database_uri": "root@/empact?parseTime=true",
"github_auth_url": "https://github.com/login/oauth/authorize", "github_auth_url": "https://github.com/login/oauth/authorize",
"github_access_token_url": "https://github.com/login/oauth/access_token", "github_access_token_url": "https://github.com/login/oauth/access_token",

View File

@ -10,7 +10,8 @@ import (
type ( type (
Config struct { 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"` DatabaseURI string `json:"app_database_uri"`
AuthURL string `json:"github_auth_url"` AuthURL string `json:"github_auth_url"`
AccessTokenURL string `json:"github_access_token_url"` AccessTokenURL string `json:"github_access_token_url"`

View File

@ -1,10 +1,12 @@
package server package server
import ( import (
"fmt"
"log" "log"
"net/http" "net/http"
"github.com/garyburd/redigo/redis" "github.com/garyburd/redigo/redis"
"github.com/localhots/empact/config"
) )
const ( const (
@ -36,10 +38,10 @@ func init() {
} }
func Start() { func Start() {
log.Println("Starting server at http://localhost:8080") log.Printf("Starting server at http://localhost:%d\n", config.C().ServerPort)
http.ListenAndServe(":8080", nil) http.ListenAndServe(fmt.Sprintf(":%d", config.C().ServerPort), nil)
} }
func dialRedis() (redis.Conn, error) { func dialRedis() (redis.Conn, error) {
return redis.Dial("tcp", ":6379") return redis.Dial("tcp", fmt.Sprintf(":%d", config.C().RedisPort))
} }