* 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"` DiskFetchFrequency int `json:"diskFetchFrequency"`
MemoryDumpFrequency int `json:"memoryDumpFrequency"` MemoryDumpFrequency int `json:"memoryDumpFrequency"`
MaxHistoryAge int `json:"maxHistoryAge"` MaxHistoryAge int `json:"maxHistoryAge"`
Listen string
} }
func GetConfiguration() DHConfig { func GetConfiguration() DHConfig {
@ -24,6 +25,8 @@ func GetConfiguration() DHConfig {
DiskFetchFrequency: 5, // default value DiskFetchFrequency: 5, // default value
MemoryDumpFrequency: 60, // default value MemoryDumpFrequency: 60, // default value
MaxHistoryAge: 2592000, // default value MaxHistoryAge: 2592000, // default value
Listen: ":8080",
} }
if val, exists := os.LookupEnv("DISK_FETCH_FREQUENCY"); exists { 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 return config
} }

View File

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