2023-03-07 20:47:49 +00:00
|
|
|
package main
|
|
|
|
|
2023-03-09 07:48:13 +00:00
|
|
|
import (
|
2023-03-17 21:27:47 +00:00
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/CPunch/gopenfusion/config"
|
2023-03-22 05:30:58 +00:00
|
|
|
"github.com/CPunch/gopenfusion/core/db"
|
2023-03-27 22:02:13 +00:00
|
|
|
"github.com/CPunch/gopenfusion/login"
|
|
|
|
"github.com/CPunch/gopenfusion/shard"
|
2023-03-09 07:48:13 +00:00
|
|
|
)
|
2023-03-07 20:47:49 +00:00
|
|
|
|
|
|
|
func main() {
|
2023-03-17 21:27:47 +00:00
|
|
|
dbHndlr, err := db.OpenLiteDB("test.db")
|
|
|
|
if err != nil {
|
|
|
|
log.Panicf("failed to open db: %v", err)
|
|
|
|
}
|
|
|
|
dbHndlr.Setup()
|
|
|
|
|
2023-03-27 22:02:13 +00:00
|
|
|
loginServer, err := login.NewLoginServer(dbHndlr, config.LOGIN_PORT)
|
2023-03-17 21:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Panicf("failed to create login server: %v", err)
|
|
|
|
}
|
|
|
|
|
2023-03-27 22:02:13 +00:00
|
|
|
shardServer, err := shard.NewShardServer(dbHndlr, config.SHARD_PORT)
|
2023-03-17 21:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Panicf("failed to create shard server: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
loginServer.AddShard(shardServer)
|
|
|
|
go loginServer.Start()
|
2023-03-09 07:48:13 +00:00
|
|
|
|
2023-03-17 21:27:47 +00:00
|
|
|
shardServer.Start()
|
2023-03-07 20:47:49 +00:00
|
|
|
}
|