package main

import (
	"log/slog"
	"os"
	"slgserver/config"
	"slgserver/net"
	"slgserver/server/loginserver"
)

func getLoginServerAddr() string {
	host := config.GetString("loginserver.host", "")
	port := config.GetString("loginserver.port", "8003")
	return host + ":" + port
}

func main() {
	if wd, err := os.Getwd(); err == nil {
		slog.Info("working directory", "dir", wd)
	} else {
		slog.Warn("get working directory failed", "error", err)
	}
	loginserver.Init()
	needSecret := config.GetBool("loginserver.need_secret", false)
	s := net.NewServer(getLoginServerAddr(), needSecret)
	s.Router(loginserver.MyRouter)
	s.Start()
}
