fix health monitor panic

This commit is contained in:
yusing 2025-02-11 07:12:08 +08:00
parent 9bed5bf872
commit 508b093278

View file

@ -164,6 +164,12 @@ func (mon *monitor) String() string {
// MarshalJSON implements json.Marshaler of HealthMonitor. // MarshalJSON implements json.Marshaler of HealthMonitor.
func (mon *monitor) MarshalJSON() ([]byte, error) { func (mon *monitor) MarshalJSON() ([]byte, error) {
res := mon.lastResult res := mon.lastResult
if res == nil {
res = &health.HealthCheckResult{
Healthy: true,
}
}
return (&JSONRepresentation{ return (&JSONRepresentation{
Name: mon.service, Name: mon.service,
Config: mon.config, Config: mon.config,