mirror of
https://github.com/tiennm99/gomoku.git
synced 2026-05-20 07:26:39 +00:00
4c068849c4
Rename - server/database/ → server/lobby/ (17 import sites + qualified references) - Package was named "database" but there is no database — it's in-memory hashmaps for players/rooms/spectators. "lobby" accurately names its role: the multiplayer game lobby state (who is in what room, joining/leaving, spectating). Ratel-online legacy cleanup - Delete server/README.md — 100% Chinese, entirely about ratel card games (斗地主/跑得快/德州扑克/麻将/骗子酒馆/Uno). Zero relevance to gomoku. - Delete server/build.sh + server/build.ps1 — multi-platform ratel-server build scripts with mixed Chinese comments, superseded by Makefile + Dockerfile. - Delete server/docs/ — Chinese Docker deployment guide + quickstart, superseded by root docs/deployment-guide.md and root README.md. - Delete server/demo.gif — ratel card-game demo screenshot. Comment fixes: update "database" references in consts/const.go and game/board.go package docs to point at "lobby" instead. go vet + go test ./... green.
44 lines
924 B
Go
44 lines
924 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/tiennm99/gomoku/server/lobby"
|
|
"github.com/tiennm99/gomoku/server/network"
|
|
"github.com/tiennm99/gomoku/server/pkg/log"
|
|
)
|
|
|
|
var port int
|
|
|
|
func main() {
|
|
flag.IntVar(&port, "p", 1999, "WebSocket server port")
|
|
flag.Parse()
|
|
|
|
// Start the idle-room reaper goroutine.
|
|
lobby.StartCleanup()
|
|
|
|
addr := fmt.Sprintf(":%d", port)
|
|
log.Infof("[main] gomoku server starting on ws://localhost%s/gomoku\n", addr)
|
|
|
|
srv := network.NewServer(addr)
|
|
|
|
// Graceful shutdown on SIGINT / SIGTERM.
|
|
// The server is blocking, so we catch signals in a background goroutine.
|
|
go func() {
|
|
quit := make(chan os.Signal, 1)
|
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
<-quit
|
|
log.Infof("[main] shutdown signal received, exiting\n")
|
|
os.Exit(0)
|
|
}()
|
|
|
|
if err := srv.Serve(); err != nil {
|
|
log.Errorf("[main] server error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|