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:
46
agent/config/schedule.go
Normal file
46
agent/config/schedule.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user