-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (36 loc) · 1.07 KB
/
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
package main
import (
logging "github.com/ipfs/go-log/v2"
"os"
"runtime"
)
var log = logging.Logger("config-creator")
var nginxConfigFilePath = os.Getenv("NGINX_CONFIG_FILE_PATH")
func init() {
if nginxConfigFilePath == "" {
log.Warnw("NGINX_CONFIG_FILE_PATH is not set. Using the default value...", "default", "/etc/nginx/nginx.conf")
nginxConfigFilePath = "/etc/nginx/nginx.conf"
}
}
func main() {
logging.SetAllLoggers(logging.LevelInfo)
log.Info("Starting the services...")
if err := checkForSavedConfig(nginxConfigFilePath); err != nil {
log.Warnw("No saved Nginx configuration found. Starting the services without it...", "error", err)
if err := setupNginxConfig(func() error {
return nil
}, []byte("{}")); err != nil {
log.Fatalw("Failed to setup Nginx: %v", "error", err)
}
}
err := startNginx()
if err != nil {
if err := setupNginxConfig(startNginx, []byte("{}")); err != nil {
log.Fatalw("Failed to setup Nginx: %v", "error", err)
}
log.Fatalw("Failed to start Nginx: %v", "error", err)
}
go startServer()
notifyAdmin()
runtime.Goexit()
}