* Custom listen

This commit is contained in:
Daniel Legt 2024-01-20 02:09:10 +02:00
parent 498aba835f
commit 21f24899a2
2 changed files with 9 additions and 1 deletions

View File

@ -12,6 +12,7 @@ type DHConfig struct {
DiskFetchFrequency int `json:"diskFetchFrequency"`
MemoryDumpFrequency int `json:"memoryDumpFrequency"`
MaxHistoryAge int `json:"maxHistoryAge"`
Listen string
}
func GetConfiguration() DHConfig {
@ -24,6 +25,8 @@ func GetConfiguration() DHConfig {
DiskFetchFrequency: 5, // default value
MemoryDumpFrequency: 60, // default value
MaxHistoryAge: 2592000, // default value
Listen: ":8080",
}
if val, exists := os.LookupEnv("DISK_FETCH_FREQUENCY"); exists {
@ -44,5 +47,9 @@ func GetConfiguration() DHConfig {
}
}
if val, exists := os.LookupEnv("LISTEN"); exists {
config.Listen = val
}
return config
}

View File

@ -9,6 +9,7 @@ import (
"syscall"
"time"
"tea.chunkbyte.com/kato/drive-health/lib/config"
"tea.chunkbyte.com/kato/drive-health/lib/svc"
"tea.chunkbyte.com/kato/drive-health/lib/web"
)
@ -20,7 +21,7 @@ func main() {
router := web.SetupRouter()
srv := &http.Server{
Addr: ":8080",
Addr: config.GetConfiguration().Listen,
Handler: router,
}