-
Notifications
You must be signed in to change notification settings - Fork 77
/
blueprint.go
45 lines (36 loc) · 1 KB
/
blueprint.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
// Package main is the entry point for the web application.
package main
import (
"log"
"runtime"
"github.com/blue-jay/blueprint/lib/boot"
"github.com/blue-jay/blueprint/lib/env"
"github.com/blue-jay/core/router"
"github.com/blue-jay/core/server"
)
// 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
config, err := env.LoadConfig("env.json")
if err != nil {
log.Fatalln(err)
}
// Register the services
boot.RegisterServices(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
)
}