-
Notifications
You must be signed in to change notification settings - Fork 71
/
main.go
51 lines (39 loc) · 1.15 KB
/
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
51
package main
import (
"Installer/router"
"Installer/service"
"flag"
log "github.com/sirupsen/logrus"
"os"
"strconv"
)
// @title Installer API
// @version 1.0
// @description some api of this
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath /api/v1
func main() {
port := flag.Int("port", 8080, "http server port")
dbInfo := flag.String("db", "127.0.0.1:3306@pxe", "database host with port, like ip:host@database")
con := flag.String("user", "root:zhangguanzhang", "user:pass connect to db")
ks := flag.String("ks", "templates/ks.tmpl", "kickstart template file")
flag.Parse()
_, err := os.Stat(*ks)
if err != nil && os.IsNotExist(err) {
log.Fatalf("kickstart template file %s %v", *ks, err)
}
if err := service.DBInit(*con, *dbInfo); err != nil {
log.Fatal(err)
}
defer service.DBClose()
Router := router.InitRouter(*ks)
if err := Router.Run(":" + strconv.Itoa(*port)); err != nil {
log.Fatal(err)
}
}