-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (32 loc) · 894 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"os"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/KonferCA/NoKap/common"
"github.com/KonferCA/NoKap/internal/server"
"github.com/joho/godotenv"
)
func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
if os.Getenv("APP_ENV") != common.PRODUCTION_ENV {
if err := godotenv.Load(); err != nil {
log.Fatal().Err(err).Msg("failed to load .env")
}
// setup pretty logging in development
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})
}
s, err := server.New(false)
if err != nil {
log.Fatal().Err(err).Msg("failed to initialized server")
}
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
err = s.Listen(":" + os.Getenv("PORT"))
if err != nil {
log.Fatal().Err(err).Str("PORT", port).Msg("failed to bind server to start accepting connections.")
}
}