feat: nlog, config hot-reload, and concurrency fixes

This commit is contained in:
xboard
2026-03-24 23:12:55 +08:00
parent 191e58b9ee
commit 7e3ad7cb23
22 changed files with 572 additions and 281 deletions
+5 -4
View File
@@ -3,11 +3,12 @@ package geodata
import (
"fmt"
"io"
"log/slog"
"net/http"
"os"
"path/filepath"
"time"
"github.com/cedar2025/xboard-node/internal/nlog"
)
const (
@@ -49,7 +50,7 @@ func Ensure(dir string, needGeoIP, needGeoSite bool, kernelType string) error {
var firstErr error
for _, f := range files {
if err := ensureFile(dir, f.name, f.url); err != nil {
slog.Warn("geo database auto-download failed", "file", f.name, "error", err)
nlog.Core().Warn("geo database auto-download failed", "file", f.name, "error", err)
if firstErr == nil {
firstErr = err
}
@@ -63,12 +64,12 @@ func ensureFile(dir, name, url string) error {
if _, err := os.Stat(dst); err == nil {
return nil
}
slog.Info("geo database missing, downloading automatically", "file", name, "url", url)
nlog.Core().Info("geo database missing, downloading automatically", "file", name, "url", url)
if err := atomicDownload(dst, url); err != nil {
return err
}
if fi, err := os.Stat(dst); err == nil {
slog.Info("geo database ready", "file", name, "size_kb", fi.Size()/1024)
nlog.Core().Info("geo database ready", "file", name, "size_kb", fi.Size()/1024)
}
return nil
}