-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (35 loc) · 669 Bytes
/
main.go
File metadata and controls
43 lines (35 loc) · 669 Bytes
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
package main
import (
"flag"
"log"
"os"
"zestream-server/configs"
"zestream-server/constants"
"zestream-server/routes"
"zestream-server/service"
)
func main() {
isConsumer := flag.Bool("consumer", false, "run service as consumer")
flag.Parse()
configs.LoadEnv()
configs.InitCloud()
conn, ch, q, _, cancel := configs.InitRabbitMQ()
if *isConsumer {
service.VideoProcessConsumer(ch, q)
return
}
r := routes.Init()
port := os.Getenv(constants.PORT)
err := r.Run(":" + port)
failOnError(err)
defer func() {
defer conn.Close()
defer ch.Close()
defer cancel()
}()
}
func failOnError(err error) {
if err != nil {
log.Fatalln(err)
}
}