-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (33 loc) · 710 Bytes
/
main.go
File metadata and controls
36 lines (33 loc) · 710 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
33
34
35
36
package main
import (
"net/http"
"os"
"github.com/hashicorp/go-hclog"
)
func main() {
logger := hclog.New(&hclog.LoggerOptions{
Name: "pear",
JSONFormat: true,
})
conf, err := NewConfig()
if err != nil {
logger.Error("failed loading config", "error", err)
os.Exit(1)
}
logger.Info("config loaded")
if conf.Debug {
logger.SetLevel(hclog.Debug)
}
pear, err := NewPearService(conf, logger)
if err != nil {
logger.Error("failed to setup Pear service", "error", err)
os.Exit(1)
}
r := NewRouter(pear)
logger.Info("starting webserver on :3333")
err = http.ListenAndServe(":"+conf.Port, r)
if err != nil {
logger.Error("http listener error", "error", err)
os.Exit(1)
}
}