-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.go
39 lines (30 loc) · 802 Bytes
/
app.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
package main
import (
"flag"
"net/http"
"os"
"github.com/teasherm/fueleconomy/global"
"github.com/teasherm/fueleconomy/handlers"
"github.com/teasherm/fueleconomy/workers"
)
var (
NWorkers = flag.Int("n", 4, "The number of workers to start")
HTTPAddr = flag.String("http", "0.0.0.0:8000", "Address to listen for HTTP requests on")
)
func main() {
global.InitLogger(os.Stdout)
dbConfig, err := global.GetDbConfig()
if err != nil {
global.Logger.Fatalln(err)
}
err = global.InitDb("postgres", dbConfig)
if err != nil {
global.Logger.Fatalln(err)
}
flag.Parse()
workers.StartDispatcher(*NWorkers)
global.Logger.Println("server listening at: ", *HTTPAddr)
if err := http.ListenAndServe(*HTTPAddr, handlers.NewRouter()); err != nil {
global.Logger.Fatalln(err.Error())
}
}