forked from scribe-org/Scribe-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (28 loc) · 808 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
package main
import (
"fmt"
"github.com/scribe-org/scribe-server/api"
"github.com/spf13/viper"
)
func main() {
// Read in the config file.
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
err := viper.ReadInConfig()
if err != nil {
_, configFileNotFound := err.(viper.ConfigFileNotFoundError)
// Config file not found; try reading config from environment variables.
if configFileNotFound {
viper.AutomaticEnv()
// Environment variables also not set.
if !viper.IsSet("hostPort") || !viper.IsSet("fileSystem") {
panic(fmt.Errorf("fatal error config environment: %w", err))
}
} else {
// Config file was found, but another error was produced.
panic(fmt.Errorf("fatal error config file: %w", err))
}
}
api.HandleRequests()
}