-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
60 lines (52 loc) · 1.96 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
52
53
54
55
56
57
58
59
60
package main
import (
_ "context"
"flag"
"fmt"
"github.com/zhukovaskychina/xmysql-server/initdb"
"github.com/zhukovaskychina/xmysql-server/server/conf"
"github.com/zhukovaskychina/xmysql-server/server/innodb/net"
"os"
"runtime"
)
const help = `
******************************************************************************************
__ ____ __ _____ ____ _ _____ ______ _______ ________ _____
\ \ / / \/ | / ____|/ __ \| | / ____| ____| __ \ \ / / ____| __ \
\ V /| \ / |_ _| (___ | | | | | _____| (___ | |__ | |__) \ \ / /| |__ | |__) |
> < | |\/| | | | |\___ \| | | | | |______\___ \| __| | _ / \ \/ / | __| | _ /
/ . \| | | | |_| |____) | |__| | |____ ____) | |____| | \ \ \ / | |____| | \ \
/_/ \_\_| |_|\__, |_____/ \___\_\______| |_____/|______|_| \_\ \/ |______|_| \_\
__/ |
|___/
******************************************************************************************
*帮助:
*1. -- help
*2. -- configPath 指定my.ini配置文件
*3. -- initialize 初始化数据库
******************************************************************************************
`
func main() {
var (
configPath = flag.String("configPath", "", "指定配置文件配置路径")
initialize = flag.Bool("initialize", false, "初始化數據庫")
)
flag.Usage = func() {
fmt.Print(help)
}
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
if configPath == nil || *configPath == "" {
fmt.Println(help)
os.Exit(1)
}
var cfg *conf.Cfg
cfg = conf.NewCfg()
cfg.Load(&conf.CommandLineArgs{ConfigPath: *configPath})
if *initialize == true {
initdb.InitDBDir(cfg)
os.Exit(1)
}
mysqlServer := net.NewMySQLServer(cfg)
mysqlServer.Start()
}