mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-17 22:19:42 +02:00
- Move health check implementations from monitor/ to new check/ package - Add h2c, tcp4/6, udp4/6 scheme support to agent health check API - Add timeout URL parameter to agent health check endpoint - Remove unused agent dependencies (dnsproviders, lego, various cloud SDKs) - Use net.JoinHostPort instead of fmt.Sprintf for port joining
29 lines
465 B
Go
29 lines
465 B
Go
package healthcheck
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/yusing/godoxy/internal/types"
|
|
)
|
|
|
|
func FileServer(path string) (types.HealthCheckResult, error) {
|
|
start := time.Now()
|
|
_, err := os.Stat(path)
|
|
lat := time.Since(start)
|
|
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
return types.HealthCheckResult{
|
|
Detail: err.Error(),
|
|
}, nil
|
|
}
|
|
return types.HealthCheckResult{}, err
|
|
}
|
|
|
|
return types.HealthCheckResult{
|
|
Healthy: true,
|
|
Latency: lat,
|
|
}, nil
|
|
}
|