58 lines
2.6 KiB
PowerShell
58 lines
2.6 KiB
PowerShell
# watchdog.ps1 - resurrects dead keyhunter lanes every 5 min
|
|
$kh = "C:\Users\User\Desktop\keyhunter"
|
|
$py = "C:\Users\User\AppData\Local\Programs\Python\Python311\python.exe"
|
|
$lanes = @(
|
|
@("gh_eternal.py", "gh_eternal_out.log", $kh),
|
|
@("validator_loop.py", "validator_loop.log", $kh),
|
|
@("eternal_export.py", "eternal_export.log", $kh),
|
|
@("gateway_importer.py", "gateway_importer.log", $kh),
|
|
@("huggingface_eternal.py", "hf_eternal.log", $kh),
|
|
@("gist_eternal.py", "gist_eternal.log", $kh),
|
|
@("grepapp_eternal.py", "grepapp_eternal.log", $kh),
|
|
@("npm_eternal.py", "npm_eternal.log", $kh),
|
|
@("pypi_eternal.py", "pypi_eternal.log", $kh),
|
|
@("gitlab_eternal.py", "gitlab_eternal.log", $kh),
|
|
@("codeberg_eternal.py", "codeberg_eternal.log", $kh),
|
|
@("forum_eternal.py", "forum_eternal.log", $kh),
|
|
@("bitbucket_eternal.py", "bitbucket_eternal.log", $kh),
|
|
@("gh_issues_eternal.py", "gh_issues.log", $kh),
|
|
@("gh_commits_eternal.py", "gh_commits.log", $kh),
|
|
@("se_eternal.py", "se_eternal.log", $kh),
|
|
@("crates_eternal.py", "crates_eternal.log", $kh),
|
|
@("rubygems_eternal.py", "rubygems_eternal.log", $kh),
|
|
@("gitea_eternal.py", "gitea_eternal.log", $kh)
|
|
@("hn_eternal.py", "hn_eternal.log", $kh),
|
|
@("nuget_eternal.py", "nuget_eternal.log", $kh),
|
|
@("packagist_eternal.py", "packagist_eternal.log", $kh),
|
|
|
|
@("eternal_v10.py", "v10_a.log", "$kh\src"),
|
|
@("eternal_v10.py", "v10_b.log", "$kh\src")
|
|
)
|
|
# track which eternal_v10 instance slot is alive (both share script name)
|
|
while ($true) {
|
|
$alive = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match 'keyhunter|eternal|validator_loop|gateway_importer' }
|
|
$aliveCmds = ($alive | ForEach-Object { $_.CommandLine }) -join "`n"
|
|
foreach ($l in $lanes) {
|
|
$script = $l[0]; $log = $l[1]; $wd = $l[2]
|
|
$isV10 = ($script -eq 'eternal_v10.py')
|
|
if ($isV10) {
|
|
$n = ([regex]::Matches($aliveCmds, 'eternal_v10')).Count
|
|
if ($n -ge 1) { continue }
|
|
$useLog = "v10_re$([guid]::NewGuid().ToString().Substring(0,4)).log"
|
|
} else {
|
|
if ($aliveCmds -match [regex]::Escape($script)) { continue }
|
|
$useLog = $log
|
|
}
|
|
try {
|
|
$p = Start-Process -FilePath $py -ArgumentList "-u", $script -WorkingDirectory $wd `
|
|
-RedirectStandardOutput "$kh\$useLog" -RedirectStandardError "$kh\err_$useLog" `
|
|
-WindowStyle Hidden -PassThru
|
|
$p.PriorityClass = "BelowNormal"
|
|
Add-Content "$kh\watchdog.log" "$(Get-Date -Format s) REVIVED $script -> $useLog"
|
|
} catch {
|
|
Add-Content "$kh\watchdog.log" "$(Get-Date -Format s) FAIL $script $_"
|
|
}
|
|
}
|
|
Start-Sleep -Seconds 300
|
|
}
|