diff --git a/Dockerfile b/Dockerfile index 6184884..a841207 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ ENV HF_MONITER_BACKEND_URL=https://monitor.hangman-lab.top \ HF_MONITER_API_KEY= \ HF_MONITER_REPORT_INTERVAL=30 \ HF_MONITER_LOG_LEVEL=info \ - HF_MONITER_ROOTFS=/host + HF_MONITER_ROOTFS=/host \ + MONITOR_PORT=0 ENTRYPOINT ["/usr/local/bin/harborforge-monitor"] diff --git a/config.example.json b/config.example.json index 49f1e22..9f32745 100644 --- a/config.example.json +++ b/config.example.json @@ -4,5 +4,6 @@ "apiKey": "replace-with-server-api-key", "reportIntervalSec": 30, "logLevel": "info", - "rootFs": "/host" + "rootFs": "/host", + "monitorPort": 0 } diff --git a/internal/config/config.go b/internal/config/config.go index ee3471c..d4e83f0 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,7 @@ type Config struct { ReportIntervalSec int `json:"reportIntervalSec"` LogLevel string `json:"logLevel"` RootFS string `json:"rootFs"` + MonitorPort int `json:"monitorPort"` } func Load(path string) (Config, error) { @@ -43,6 +44,7 @@ func Load(path string) (Config, error) { cfg.ReportIntervalSec = getenvIntAny([]string{"HF_MONITER_REPORT_INTERVAL", "HF_MONITOR_REPORT_INTERVAL"}, cfg.ReportIntervalSec) cfg.LogLevel = getenvAny([]string{"HF_MONITER_LOG_LEVEL", "HF_MONITOR_LOG_LEVEL"}, cfg.LogLevel) cfg.RootFS = getenvAny([]string{"HF_MONITER_ROOTFS", "HF_MONITOR_ROOTFS"}, cfg.RootFS) + cfg.MonitorPort = getenvIntAny([]string{"MONITOR_PORT", "HF_MONITOR_PORT"}, cfg.MonitorPort) if cfg.BackendURL == "" { return cfg, fmt.Errorf("backendUrl is required") @@ -88,6 +90,9 @@ func merge(dst *Config, src Config) { if src.RootFS != "" { dst.RootFS = src.RootFS } + if src.MonitorPort > 0 { + dst.MonitorPort = src.MonitorPort + } } func getenvAny(keys []string, fallback string) string {