chore: UNCLOUD_HEALTH_MONITOR_PERIOD accepts duration (10s, 500ms, 0)

This commit is contained in:
Pasha Sviderski
2026-03-01 08:08:57 +10:00
parent eaa4455320
commit b48ebe2acc
+6 -6
View File
@@ -6,7 +6,6 @@ import (
"io" "io"
"net/netip" "net/netip"
"os" "os"
"strconv"
"strings" "strings"
"time" "time"
@@ -261,14 +260,15 @@ func (c *ServiceContainer) UnmarshalJSON(data []byte) error {
return nil return nil
} }
// DefaultHealthMonitorPeriod is the default duration to wait before checking that the container is still running // DefaultHealthMonitorPeriod is the default duration (5 seconds) to wait before checking that the container is still
// and not restarting. Can be overridden with the UNCLOUD_HEALTH_MONITOR_PERIOD_MS environment variable. // running and not restarting. Can be overridden with the UNCLOUD_HEALTH_MONITOR_PERIOD environment variable
// (e.g. "10s" or "0").
var DefaultHealthMonitorPeriod = defaultHealthMonitorPeriod() var DefaultHealthMonitorPeriod = defaultHealthMonitorPeriod()
func defaultHealthMonitorPeriod() time.Duration { func defaultHealthMonitorPeriod() time.Duration {
if v, ok := os.LookupEnv("UNCLOUD_HEALTH_MONITOR_PERIOD_MS"); ok { if v, ok := os.LookupEnv("UNCLOUD_HEALTH_MONITOR_PERIOD"); ok {
if ms, err := strconv.Atoi(v); err == nil { if d, err := time.ParseDuration(v); err == nil {
return time.Duration(ms) * time.Millisecond return d
} }
} }