forked from jpillora/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (33 loc) · 899 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
package main
import (
"log"
"net"
"net/http"
"strconv"
"time"
"github.com/jpillora/installer/handler"
"github.com/jpillora/opts"
"github.com/jpillora/requestlog"
)
var version = "0.0.0-src"
func main() {
c := handler.DefaultConfig
opts.New(&c).Repo("github.com/jpillora/installer").Version(version).Parse()
log.Printf("default user is '%s', github token set: %v", c.User, c.Token != "")
l, err := net.Listen("tcp4", "0.0.0.0:"+strconv.Itoa(c.Port))
if err != nil {
log.Fatal(err)
}
log.Printf("listening on port %d...", c.Port)
h := &handler.Handler{Config: c}
lh := requestlog.WrapWith(h, requestlog.Options{
TrustProxy: true, // assume will be run in paas
Filter: func(r *http.Request, code int, duration time.Duration, size int64) bool {
return r.URL.Path != "/healthz"
},
})
if err := http.Serve(l, lh); err != nil {
log.Fatal(err)
}
log.Print("exiting")
}