You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
761 B
Go

2 weeks ago
package main
import (
"context"
"flag"
"log/slog"
"os"
"os/signal"
"syscall"
2 weeks ago
"code.ndumas.com/ndumas/muddy/core"
"code.ndumas.com/ndumas/muddy/systems"
2 weeks ago
)
func main() {
var (
level string
)
flag.StringVar(&level, "level", "INFO", "Log level: INFO/info, DEBUG/debug, or ERROR/error")
flag.Parse()
app := core.New(level)
2 weeks ago
rs := &systems.RoomSystem{
Rooms: make(map[uint64]*systems.Room, 0),
L: app.L.With(slog.String("system", "room")),
}
app.W.AddSystem(rs)
app.L.With(
slog.Int("room count", len(rs.Rooms)),
).Info("setup complete")
2 weeks ago
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
cancel()
}()
app.Run(ctx)
2 weeks ago
}