diff --git a/server/cmd/server/main.go b/server/cmd/server/main.go index b59547a..ebb5bc7 100644 --- a/server/cmd/server/main.go +++ b/server/cmd/server/main.go @@ -33,12 +33,17 @@ func main() { if err != nil { log.Fatal(err) } - if err := migrate.Apply(ymt); err != nil { - log.Fatal(err) + if ymtDSN != "" { + if err := migrate.Apply(ymt); err != nil { + log.Fatal(err) + } + } else { + log.Println("skip migrations: YMT DSN missing") } r := api.NewRouter(ymt, marketing) - srv := &http.Server{Addr: ":8080", Handler: r, ReadTimeout: 15 * time.Second, WriteTimeout: 60 * time.Second} - log.Println("server listening on :8080") + addr := ":" + func() string { s := os.Getenv("PORT"); if s == "" { return "8080" }; return s }() + srv := &http.Server{Addr: addr, Handler: r, ReadTimeout: 15 * time.Second, WriteTimeout: 60 * time.Second} + log.Println("server listening on ", addr) log.Fatal(srv.ListenAndServe()) }