-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
32 lines (24 loc) · 731 Bytes
/
main.go
File metadata and controls
32 lines (24 loc) · 731 Bytes
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
package main
import (
"log"
"net/http"
"github.com/guilhebl/go-offer/offer"
)
// runs app in PROD mode
func main() {
run("prod")
}
// run starts the app
// mode - PROD or TEST modes will use different config values depending on mode.
func run(mode string) {
const defaultPort = ":8080"
log.Printf("Server starting - port %s - mode %s", defaultPort, mode)
// build module and setup server to listen at default port
startServer(defaultPort, mode)
}
// starts a new server instance using mode config and port
func startServer(port, mode string) {
// inits app module setting up worker pool and other global scoped objects
offer.BuildInstance(mode)
log.Fatal(http.ListenAndServe(port, offer.GetInstance().Router))
}