-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 860 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
39
40
41
42
package main
import (
"flag"
"log"
"DreamsMoney/feelgoodfoodsnv.com/ordering/app"
"DreamsMoney/feelgoodfoodsnv.com/ordering/config"
"DreamsMoney/feelgoodfoodsnv.com/ordering/http/webserver"
"DreamsMoney/feelgoodfoodsnv.com/ordering/templates"
)
func main() {
jsonConfigFile := parseCommandLineOptions()
if jsonConfigFile == "" {
jsonConfigFile = "config.json"
}
config := config.LoadConfig(jsonConfigFile)
syncChannel := make(chan struct{})
webserver.ServeHTTP(config, syncChannel)
app.ProcessOrders(config, syncChannel)
templates.RunTemplateOutputInterval(config, syncChannel)
for {
<-syncChannel
}
}
func parseCommandLineOptions() string {
flag.Parse()
arguments := flag.Args()
if len(arguments) > 1 {
log.Fatalf("Usage: feelgood-server <config file path>")
}
if len(arguments) == 0 {
return ""
}
return arguments[0]
}