| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // API doc: https://wiki.summercamp.local/display/PIN/Pinguin+server+API
- package main
- import (
- "log"
- "os"
- "runtime/pprof"
- "battlecamp-go/flag"
- "battlecamp-go/battlecamp-go-gameserver/gameserver"
- )
- var gameServer gameserver.GameServer = gameserver.New()
- func main() {
- initLogging()
- log.Println("Game server version 0.1")
- flag.ParseFlags()
- if *flag.CpuProfile != "" {
- f, err := os.Create(*flag.CpuProfile)
- if err != nil {
- log.Printf("ERROR: %v\n", err)
- } else {
- pprof.StartCPUProfile(f)
- }
- }
- gameServer.Serve()
- }
- func initLogging() {
- logFile, err := os.Create("server.log")
- if err == nil {
- log.SetOutput(logFile)
- } else {
- log.Println("ERROR: Cannot open log file, using console.")
- log.Printf("%v=n", err)
- }
- }
|