package main

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

func getServerAddr() string {
	host := config.GetString("slgserver.host", "")
	port := config.GetString("slgserver.port", "8001")
	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)
	}
	run.Init()
	needSecret := config.GetBool("slgserver.need_secret", false)
	s := net.NewServer(getServerAddr(), needSecret)
	s.Router(run.MyRouter)
	s.Start()
}
