Skip to content

Commit 626949b

Browse files
author
Eolink
authored
Merge pull request #29 from Dot-Liu/master
新增编排
2 parents df660d6 + 887d513 commit 626949b

File tree

431 files changed

+8976
-10473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+8976
-10473
lines changed

app/console/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
/html/
2+
/console
3+
/work/
4+
/log/
5+
/logs/
6+
/cert/
7+
/config/
8+
/db/
9+
/static/
10+
/sql/

app/console/config/cluster.yaml

-17
This file was deleted.

app/console/config/goku.conf

-7
This file was deleted.

app/console/main.go

+23-24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"flag"
5+
56
"github.com/eolinker/goku-api-gateway/console/module/account"
67
log "github.com/eolinker/goku-api-gateway/goku-log"
78

@@ -12,60 +13,58 @@ import (
1213
)
1314

1415
var (
15-
// UserPassword 用户密码
16-
UserPassword string
17-
// UserName 用户名
18-
UserName string
19-
// ConfFilePath 配置文件地址
20-
ConfFilePath = "./config/goku.conf"
21-
16+
userPassword string
17+
userName string
18+
confFilePath = "./config/goku.conf"
2219
)
2320

2421
func main() {
25-
flag.StringVar(&ConfFilePath, "c", "./config/goku.conf", "Please provide a valid configuration file path")
26-
flag.StringVar(&UserName, "u", "", "Please provide user name")
27-
flag.StringVar(&UserPassword, "p", "", "Please provide user password")
22+
flag.StringVar(&confFilePath, "c", "./config/goku.conf", "Please provide a valid configuration file path")
23+
flag.StringVar(&userName, "u", "", "Please provide user name")
24+
flag.StringVar(&userPassword, "p", "", "Please provide user password")
2825
isDebug := flag.Bool("debug", false, "")
2926

3027
flag.Parse()
3128
if *isDebug {
3229
log.StartDebug()
3330
}
3431
// 初始化配置
35-
if err := conf.ReadConfigure(ConfFilePath); err != nil {
32+
if err := conf.ReadConfigure(confFilePath); err != nil {
3633
log.Panic(err)
3734
return
3835
}
3936
// 初始化db
4037
console.InitDatabase()
4138
console.InitLog()
4239

43-
console.InitClusters()
40+
//console.InitClusters()
4441
// 其他需要初始化的模块
4542
_ = general.General()
4643
// 检测是否安装
47-
48-
if s, err := account.CheckSuperAdminCount(); err != nil {
49-
log.Panic(err)
50-
return
51-
} else if s == 0 {
52-
if UserName == "" {
44+
s, err := account.CheckSuperAdminCount()
45+
if err != nil {
46+
err = console.InitTable()
47+
if err != nil {
48+
log.Panic(err)
49+
return
50+
}
51+
}
52+
if s == 0 {
53+
if userName == "" {
5354
log.Fatal("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
54-
//fmt.Println("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
5555
return
5656
}
57-
if UserPassword == "" {
57+
if userPassword == "" {
5858
log.Fatal("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
59-
//fmt.Println("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
59+
6060
return
6161
}
6262

6363
// 用户注册
64-
password := utils.Md5(utils.Md5(UserPassword))
65-
f := console.Register(UserName, password)
64+
password := utils.Md5(utils.Md5(userPassword))
65+
f := console.Register(userName, password)
6666
if !f {
6767
log.Fatal("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
68-
//fmt.Println("[ERROR] Fail to create administrator. Please try again or contact technical support of eoLinker GOKU API Gateway.")
6968
return
7069
}
7170
}

app/console/static/scripts/app-9b3cb8f46b.js

-22
This file was deleted.

app/console/static/styles/app-6e5f7694bf.css

-16
This file was deleted.

app/goku-node/main.go

-91
This file was deleted.

app/node/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/work/
2+
/logs/
3+
/node

app/node/driver.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
5+
"github.com/eolinker/goku-api-gateway/goku-service/driver/consul"
6+
"github.com/eolinker/goku-api-gateway/goku-service/driver/eureka"
7+
"github.com/eolinker/goku-api-gateway/goku-service/driver/static"
8+
9+
)
10+
11+
func init() {
12+
consul.Register()
13+
eureka.Register()
14+
static.Register()
15+
}

app/node/flag.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import "flag"
4+
5+
//ParseFlag 获取命令行参数
6+
func ParseFlag() (port int, admin string, staticConfigFile string, isDebug bool) {
7+
adminP := flag.String("admin", "", "Please provide a valid host!")
8+
portP := flag.Int("port", 0, "Please provide a valid listen port!")
9+
staticConfigFileP := flag.String("config", "", "Please provide a config file")
10+
11+
isDebugP := flag.Bool("debug", false, "")
12+
13+
flag.Parse()
14+
15+
return *portP, *adminP, *staticConfigFileP, *isDebugP
16+
17+
}

app/node/main.go

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"github.com/eolinker/goku-api-gateway/config"
6+
log "github.com/eolinker/goku-api-gateway/goku-log"
7+
console2 "github.com/eolinker/goku-api-gateway/node/console"
8+
"github.com/eolinker/goku-api-gateway/node/gateway"
9+
"github.com/eolinker/goku-api-gateway/node/router/httprouter"
10+
"github.com/eolinker/goku-api-gateway/node/server"
11+
"runtime"
12+
)
13+
14+
func main() {
15+
runtime.GOMAXPROCS(runtime.NumCPU())
16+
17+
port, admin, staticConfigFile, isDebug := ParseFlag()
18+
19+
if isDebug {
20+
log.StartDebug()
21+
}
22+
23+
if port == 0{
24+
flag.Usage()
25+
26+
return
27+
}
28+
29+
if admin != "" {
30+
// 从控制台启动,
31+
console := console2.NewConsole(port, admin)
32+
ser := server.NewServer(port)
33+
ser.SetConsole(console)
34+
log.Fatal(ser.Server())
35+
36+
} else if staticConfigFile != "" {
37+
38+
// 从静态文件启动
39+
c, err := config.ReadConfig(staticConfigFile)
40+
if err != nil {
41+
log.Panic("read config from :", staticConfigFile, "\t", err)
42+
}
43+
44+
server.SetLog(c.Log)
45+
server.SetAccessLog(c.AccessLog)
46+
47+
48+
r, err := gateway.Parse(c, httprouter.Factory())
49+
if err != nil {
50+
log.Panic("parse config error:", err)
51+
}
52+
53+
54+
55+
ser := server.NewServer(port)
56+
e := ser.SetRouter(r)
57+
if e != nil {
58+
log.Panic("init router error:", e)
59+
}
60+
log.Fatal(ser.Server())
61+
} else {
62+
//
63+
flag.Usage()
64+
return
65+
}
66+
}

build/cmd/build-node.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ then
1717
fi
1818

1919

20-
buildApp goku-node $VERSION
20+
buildApp node $VERSION
2121

2222

23-
OUTPATH="${BasePath}/out/goku-node-${VERSION}"
23+
OUTPATH="${BasePath}/out/node-${VERSION}"
2424
mkdir ${OUTPATH}/plugin
25-
cp -a ${BasePath}/build/goku-node/resources/* ${OUTPATH}/
25+
cp -a ${BasePath}/build/node/resources/* ${OUTPATH}/
2626
if [ -d "${BasePath}/out/plugins" ];then
2727
cp -a ${BasePath}/out/plugins/* ${OUTPATH}/plugin/
2828
fi

build/cmd/package-node.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd ${BasePath}/
55

66

77
VERSION=$(genVersion $1)
8-
folder="${BasePath}/out/goku-node-${VERSION}"
8+
folder="${BasePath}/out/node-${VERSION}"
99
if [[ ! -d "$folder" ]]
1010
then
1111

@@ -15,6 +15,6 @@ then
1515
exit 1
1616
fi
1717
fi
18-
packageApp goku-node $VERSION
18+
packageApp node $VERSION
1919

2020
cd ${ORGPATH}

build/console/resources/db/sqlite3/.gitignore

Whitespace-only changes.

build/console/resources/goku.conf.tpl

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
listen_port: 7000
22
admin_bind: 127.0.0.1:7005
3-
db_host: 127.0.0.1
4-
db_port: 3306
5-
db_name: goku_ee
6-
db_user: root
7-
db_password: root

0 commit comments

Comments
 (0)