-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
53 lines (46 loc) · 1009 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
47
48
49
50
51
52
53
package main
import (
"fmt"
"log"
"os"
"strconv"
"sync"
"github.com/badico-cloud-hub/pubsub/api"
"github.com/badico-cloud-hub/pubsub/infra"
"github.com/badico-cloud-hub/pubsub/setup"
"github.com/joho/godotenv"
)
func main() {
if err := godotenv.Load(); err != nil {
log.Fatal(err)
}
isServerEnv := os.Getenv("IS_SERVER")
isServer, err := strconv.ParseBool(isServerEnv)
if err != nil {
log.Fatal(err)
}
// logManager := infra.NewLogManager()
// logManager.StartProducer()
// defer func() {
// logManager.StopProducer()
// }()
if isServer {
fmt.Printf("RUNNING API PUBSUB\n")
port := os.Getenv("PORT")
api := api.NewServer(port)
// api.LogManager = logManager
api.AllRouters()
if err := api.Run(); err != nil {
log.Fatal(err)
}
} else {
fmt.Printf("RUNNING CONSUMER PUBSUB\n")
wg := &sync.WaitGroup{}
sqs := infra.NewSqsClient()
if err := sqs.Setup(); err != nil {
log.Fatal(err)
}
setup.SetupNotifyEventConsumer(sqs.Client, wg)
wg.Wait()
}
}