2014-07-10 12:19:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2014-07-13 10:14:26 +00:00
|
|
|
const (
|
|
|
|
DefaultProductionStorage = "burlesque.kch#opts=c#zcomp=gz#msiz=524288000"
|
|
|
|
)
|
|
|
|
|
2014-07-10 12:19:39 +00:00
|
|
|
type (
|
|
|
|
Config struct {
|
|
|
|
Storage string
|
|
|
|
Env string
|
|
|
|
Port int
|
2014-07-12 10:39:00 +00:00
|
|
|
Rollbar string
|
2014-07-10 12:19:39 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
cfg = Config{}
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetupConfig() {
|
2014-07-13 10:14:26 +00:00
|
|
|
cfg.Storage = *flag.String("storage", "-", "Kyoto Cabinet storage path (e.g. "+DefaultProductionStorage+")")
|
2014-07-10 12:19:39 +00:00
|
|
|
cfg.Env = *flag.String("environment", "development", "Process environment: development or production")
|
2014-07-12 12:36:01 +00:00
|
|
|
cfg.Port = *flag.Int("port", 4401, "Server HTTP port")
|
2014-07-12 10:39:00 +00:00
|
|
|
cfg.Rollbar = *flag.String("rollbar", "", "Rollbar token")
|
2014-07-10 12:19:39 +00:00
|
|
|
flag.Parse()
|
2014-07-13 10:14:26 +00:00
|
|
|
|
|
|
|
if cfg.Env == "production" && cfg.Storage == "-" {
|
|
|
|
cfg.Storage = DefaultProductionStorage
|
|
|
|
}
|
2014-07-10 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Config) PortString() string {
|
|
|
|
return fmt.Sprintf(":%d", cfg.Port)
|
|
|
|
}
|