()
| 25 | var timeStart = time.Now() |
| 26 | |
| 27 | func main() { |
| 28 | log.Infolnf("Zeppelin 1.21 Minecraft server with %s on platform %s-%s", runtime.Version(), runtime.GOOS, runtime.GOARCH) |
| 29 | |
| 30 | max, ok := console.GetFlag("xmem") |
| 31 | if ok { |
| 32 | m, err := util.ParseSizeUnit(max) |
| 33 | if err == nil { |
| 34 | debug.SetMemoryLimit(int64(m)) |
| 35 | log.Infolnf("Memory usage is limited to %s", util.FormatSizeUnit(m)) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | if slices.Index(os.Args, "--cpuprof") != -1 { |
| 40 | if f, err := os.Create("zeppelin-cpu-profile"); err == nil { |
| 41 | pprof.StartCPUProfile(f) |
| 42 | log.Infoln("Started CPU profiler (writing to zeppelin-cpu-profile)") |
| 43 | |
| 44 | defer func() { |
| 45 | log.Infoln("Stopped CPU profiler") |
| 46 | pprof.StopCPUProfile() |
| 47 | f.Close() |
| 48 | }() |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if slices.Index(os.Args, "--memprof") != -1 { |
| 53 | defer func() { |
| 54 | log.InfolnClean("Writing memory profile to zeppelin-mem-profile") |
| 55 | f, _ := os.Create("zeppelin-mem-profile") |
| 56 | pprof.Lookup("allocs").WriteTo(f, 0) |
| 57 | f.Close() |
| 58 | }() |
| 59 | } |
| 60 | |
| 61 | cfg := loadConfig() |
| 62 | if cfg.LevelSeed == "" { |
| 63 | cfg.LevelSeed = strconv.FormatInt(rand.Int63(), 10) |
| 64 | } |
| 65 | |
| 66 | w, err := world.NewWorld(cfg) |
| 67 | if err != nil { |
| 68 | log.Errorlnf("Error preparing level: %v", w) |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | log.Infof("Binding server to %s:%d\n", cfg.ServerIp, cfg.ServerPort) |
| 73 | |
| 74 | rawTerminal := slices.Index(os.Args, "--no-raw-terminal") == -1 |
| 75 | |
| 76 | srv, err := server.New(cfg, w) |
| 77 | if err != nil { |
| 78 | log.Errorln("Error binding server:", err) |
| 79 | return |
| 80 | } |
| 81 | srv.CommandManager = command.NewManager(srv, commands.Commands...) |
| 82 | if rawTerminal { |
| 83 | oldState, err := term.MakeRaw(int(os.Stdin.Fd())) |
| 84 | if err != nil { |
nothing calls this directly
no test coverage detected