-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.go
56 lines (51 loc) · 1.22 KB
/
dashboard.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
54
55
56
// Package main is the entry point for the web application.
package main
import (
"fmt"
"dashboard/lib/system/router"
"dashboard/lib/config/env"
"dashboard/lib/system/boot"
"dashboard/lib/system/server"
"log"
"runtime"
"sync"
)
// init sets runtime settings.
func init() {
// Verbose logging with file name and line number
log.SetFlags(log.Lshortfile)
// Use all CPU cores
runtime.GOMAXPROCS(runtime.NumCPU())
}
// main loads the configuration file, registers the services, applies the
// middleware to the router, and then starts the HTTP and HTTPS listeners.
func main() {
// Load the configuration file
file := []string{"dashboard.json"}
var wg sync.WaitGroup
for _, f := range file {
config, err := env.LoadConfig(f)
if err != nil {
log.Fatalln(err)
}
if config.Enabled == true {
switch f {
case "dashboard.json":
wg.Add(1)
go func() {
fmt.Println(config)
boot.RegisterDashboard(config)
// Retrieve the middleware
handler := boot.SetUpMiddleware(router.Instance())
// Start the HTTP and HTTPS listeners
server.Run(
handler, // HTTP handler
handler, // HTTPS handler
config.Server, // Server settings
)
}()
}
}
}
wg.Wait()
}