Configure app and server ports
This commit is contained in:
parent
ae4d1d13a2
commit
16e8319e82
|
@ -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",
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue