-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (38 loc) · 902 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 (
"github.com/spf13/viper"
"log"
"video_transcoding_worker/worker"
)
func Init() {
err := viper.BindEnv("endpoint", "endpoint")
if err != nil {
return
}
err = viper.BindEnv("jwt_token", "jwt_token")
if err != nil {
return
}
err = viper.BindEnv("message_queue", "message_queue")
if err != nil {
return
}
viper.AutomaticEnv()
viper.SetConfigType("yaml")
viper.SetConfigName("config")
viper.AddConfigPath(".")
err = viper.ReadInConfig()
if err != nil {
log.Printf("Error reading config file, %s", err)
}
}
func main() {
Init()
endpoint := viper.GetString("endpoint")
jwtToken := viper.GetString("jwt_token")
messageQueue := viper.GetString("message_queue")
if len(endpoint) == 0 || len(jwtToken) == 0 || len(messageQueue) == 0 {
log.Fatal("Please provide all required environment variables")
}
worker.Setup(endpoint, jwtToken, messageQueue)
}