-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
44 lines (34 loc) · 978 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
42
43
44
package main
import (
"context"
"net/http"
"os"
"time"
"github.com/CSUOS/rabums/pkg/config"
"github.com/CSUOS/rabums/pkg/database"
"github.com/CSUOS/rabums/pkg/server"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
//go:generate oapi-codegen --package=server --generate chi-server,types,spec -o pkg/server/server.gen.go api/swagger.yaml
func main() {
log.Info().Msg("Hello")
ctx := context.Background()
// Set Logging Format
if config.Mode == config.ModeProd {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
} else {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC1123})
}
log.Logger = log.Logger.With().Caller().Timestamp().Logger()
ctx = log.Logger.WithContext(ctx)
config.Init(ctx)
// Initializing pkgs
database.Init(ctx)
defer database.Close(ctx)
r := server.Init(ctx)
// Listening
log.Info().Msg("Listening on :3000")
http.ListenAndServe(":3000", r)
}