server.go 1.5 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5
package console

import (
	"net/http"

黄孟柱 已提交
6
	log "github.com/eolinker/goku-api-gateway/goku-log"
E
eoLinker API Management 已提交
7

黄孟柱 已提交
8 9 10 11 12
	"github.com/eolinker/goku-api-gateway/console/controller/api"
	"github.com/eolinker/goku-api-gateway/console/controller/script"
	"github.com/eolinker/goku-api-gateway/console/controller/strategy"
	cluster2 "github.com/eolinker/goku-api-gateway/server/cluster"
	monitor_read "github.com/eolinker/goku-api-gateway/server/monitor/monitor-read"
E
eoLinker API Management 已提交
13

黄孟柱 已提交
14 15 16
	"github.com/eolinker/goku-api-gateway/common/conf"
	"github.com/eolinker/goku-api-gateway/console/admin"
	"github.com/eolinker/goku-api-gateway/console/module/account"
E
eoLinker API Management 已提交
17 18
)

Y
Your Name 已提交
19
//Server 服务
E
eoLinker API Management 已提交
20 21 22 23
func Server() {
	//go monitor.MonitorNode()
	monitor_read.InitMonitorRead(cluster2.GetList())
	script.UpdateTables()
Y
Your Name 已提交
24
	api.UpdateAllAPIPluginUpdateTag()
E
eoLinker API Management 已提交
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 61 62 63 64 65 66 67
	strategy.UpdateAllStrategyPluginUpdateTag()
	bind, has := conf.Get("admin_bind")

	ec := make(chan error, 2)
	if has {
		go func() {
			err := admin.StartServer(bind)
			ec <- err
		}()
	} else {
		log.Panic("[ERROR] Illegal admin_bind!")
	}

	port, has := conf.Get("listen_port")
	if has {
		go func() {
			log.Print("Listen: ", port)
			log.Print("Start Successfully!")
			err := http.ListenAndServe(":"+port, nil)

			ec <- err
		}()
	} else {
		log.Panic("[ERROR] Illegal listen port!")
	}
	// go func() {
	// 	err := http.ListenAndServe(":6060", nil)
	// 	ec <- err
	// }()

	for {
		select {
		case e, ok := <-ec:
			if !ok {
				break
			}
			log.Fatal(e)
		}

	}

}

Y
Your Name 已提交
68
// Register 用户注册
E
eoLinker API Management 已提交
69 70 71
func Register(loginCall, loginPassword string) bool {
	return account.Register(loginCall, loginPassword)
}