forked from soyking/e3w
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (42 loc) · 879 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 (
"flag"
"fmt"
"github.com/coreos/etcd/version"
"github.com/gin-gonic/gin"
"github.com/soyking/e3w/conf"
"github.com/soyking/e3w/e3ch"
"github.com/soyking/e3w/routers"
"os"
)
const (
PROGRAM_NAME = "e3w"
PROGRAM_VERSION = "0.0.2"
)
var configFilepath string
func init() {
flag.StringVar(&configFilepath, "conf", "conf/config.default.ini", "config file path")
rev := flag.Bool("rev", false, "print rev")
flag.Parse()
if *rev {
fmt.Printf("[%s v%s]\n[etcd %s]\n",
PROGRAM_NAME, PROGRAM_VERSION,
version.Version,
)
os.Exit(0)
}
}
func main() {
config, err := conf.Init(configFilepath)
if err != nil {
panic(err)
}
client, err := e3ch.NewE3chClient(config)
if err != nil {
panic(err)
}
router := gin.Default()
router.UseRawPath = true
routers.InitRouters(router, config, client)
router.Run(":" + config.Port)
}