|
|
|
@ -403,8 +403,13 @@ func Serve() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func connectToDatabase(app *app) { |
|
|
|
|
log.Info("Connecting to database...") |
|
|
|
|
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()))) |
|
|
|
|
if app.cfg.Database.Type != "mysql" { |
|
|
|
|
log.Error("Invalid database type '%s'. Only 'mysql' is supported right now.", app.cfg.Database.Type) |
|
|
|
|
os.Exit(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.Info("Connecting to %s database...", app.cfg.Database.Type) |
|
|
|
|
db, err := sql.Open(app.cfg.Database.Type, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()))) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("%s", err) |
|
|
|
|
os.Exit(1) |
|
|
|
|