-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
46 lines (37 loc) · 914 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
45
46
package main
import (
"clamp-core/config"
"clamp-core/handlers"
"clamp-core/listeners"
"clamp-core/migrations"
"clamp-core/models"
"clamp-core/repository"
"os"
log "github.com/sirupsen/logrus"
)
func main() {
logLevel, err := log.ParseLevel(config.ENV.LogLevel)
if err != nil {
log.Fatalf("parsing log level failed: %s", err)
}
log.SetLevel(logLevel)
log.Info("Pinging DB...")
err = repository.GetDB().Ping()
if err != nil {
log.Fatalf("DB ping failed: %s", err)
}
var cliArgs models.CLIArguments = os.Args[1:]
os.Setenv("PORT", config.ENV.PORT)
migrations.Migrate()
if cliArgs.Parse().Find("migrate-only", "no") == "yes" {
os.Exit(0)
}
if config.ENV.EnableRabbitMQIntegration {
listeners.AMQPStepResponseListener.Listen()
}
if config.ENV.EnableKafkaIntegration {
listeners.KafkaStepResponseListener.Listen()
}
handlers.LoadHTTPRoutes()
log.Info("Calling listener")
}