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>
23 lines
557 B
Go
23 lines
557 B
Go
//go:build !windows && !wasm
|
|
|
|
package main
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// 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 stat unix.Statfs_t
|
|
if err := unix.Statfs(path, &stat); err != nil {
|
|
return 0, false
|
|
}
|
|
|
|
// Calculate available space in bytes, then convert to MB
|
|
availableBytes := stat.Bavail * uint64(stat.Bsize)
|
|
availableMB := availableBytes / (1024 * 1024)
|
|
|
|
return availableMB, true
|
|
}
|