forked from koron/nvgd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (44 loc) · 979 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
43
44
45
46
47
48
49
50
package main
import (
_ "embed"
"flag"
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"github.com/koron/nvgd/config"
"github.com/koron/nvgd/core"
"github.com/koron/nvgd/internal/version"
_ "github.com/koron/nvgd/plugins"
"github.com/koron/nvgd/protocol/help"
)
var (
configOpt = flag.String("c", "nvgd.conf.yml", "configuration file")
pprofAddr = flag.String("pprofaddr", "", "address for pprof server")
verFlag = flag.Bool("version", false, "show version")
)
//go:embed README.md
var readme string
func init() {
help.Text = readme
}
func main() {
flag.Parse()
if *verFlag {
fmt.Println(version.Version)
return
}
c, err := config.LoadConfig(*configOpt)
if err != nil {
log.Fatalf("failed to load config: %s", err)
}
if *pprofAddr != "" {
log.Printf("start pprof on %s", *pprofAddr)
go func() {
log.Println(http.ListenAndServe(*pprofAddr, nil))
}()
}
if err := core.Run(c); err != nil {
log.Fatalf("failed to run server: %s", err)
}
}