feat: implement health checks in daemon event loop (bd-gqo)
Add health checks to checkDaemonHealth() function: - Database integrity check using PRAGMA quick_check(1) - Disk space check with 100MB warning threshold (platform-specific) - Memory usage check with 500MB heap warning threshold Platform-specific disk space implementations: - Unix: uses unix.Statfs - Windows: uses windows.GetDiskFreeSpaceEx - WASM: returns unsupported (false) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
33
cmd/bd/daemon_health_windows.go
Normal file
33
cmd/bd/daemon_health_windows.go
Normal file
@@ -0,0 +1,33 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// checkDiskSpace returns the available disk space in MB for the given path.
|
||||
// Returns (availableMB, true) on success, (0, false) on failure.
|
||||
func checkDiskSpace(path string) (uint64, bool) {
|
||||
var freeBytesAvailable, totalBytes, totalFreeBytes uint64
|
||||
|
||||
pathPtr, err := windows.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
err = windows.GetDiskFreeSpaceEx(
|
||||
pathPtr,
|
||||
(*uint64)(unsafe.Pointer(&freeBytesAvailable)),
|
||||
(*uint64)(unsafe.Pointer(&totalBytes)),
|
||||
(*uint64)(unsafe.Pointer(&totalFreeBytes)),
|
||||
)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// Convert to MB
|
||||
availableMB := freeBytesAvailable / (1024 * 1024)
|
||||
return availableMB, true
|
||||
}
|
||||
Reference in New Issue
Block a user