Add configurable install paths and enforce mining schedules.

Builder and Settings expose install base/subfolder with live preview. Agent embeds on first exe run to the configured path, pauses for idle CPU and scheduled windows, and reports real system CPU usage.
This commit is contained in:
drjones
2026-05-26 23:39:51 -07:00
parent f7d6dcf542
commit 1313c553e7
20 changed files with 662 additions and 24 deletions

46
agent/config/schedule.go Normal file
View File

@@ -0,0 +1,46 @@
package config
import (
"strings"
"time"
)
func (c RuntimeConfig) MiningModeNormalized() string {
mode := strings.ToLower(strings.TrimSpace(c.MiningMode))
if mode == "" {
return "always"
}
return mode
}
func (c RuntimeConfig) InScheduleWindow(now time.Time) bool {
startMin, okStart := parseClockMinutes(c.ScheduleStart)
endMin, okEnd := parseClockMinutes(c.ScheduleEnd)
if !okStart || !okEnd {
return true
}
nowMin := now.Hour()*60 + now.Minute()
if startMin == endMin {
return true
}
if startMin < endMin {
return nowMin >= startMin && nowMin < endMin
}
return nowMin >= startMin || nowMin < endMin
}
func parseClockMinutes(value string) (int, bool) {
value = strings.TrimSpace(value)
if value == "" {
return 0, false
}
parsed, err := time.Parse("15:04", value)
if err != nil {
parsed, err = time.Parse("15:04:05", value)
if err != nil {
return 0, false
}
}
return parsed.Hour()*60 + parsed.Minute(), true
}