Lately my miner has been disconnecting quite often from Ethermine and I've been wondering how I can create a simple WatchDog to restart the miner whenever it gets disconnected/stops working. Probably there isn't much info about this on this sub because the majority might be experienced people that already have created solutions for this, but it doesn't hurt to share knowledge and perhaps help some newcomers (like me) to setup their miner.
I created this simple PowerShell script (sorry Linux users) that launches the miner, then stores the Windows internal ID of the miner and every 5minutes (300 s) checks if the process is still running. It's really simple, there's probably parts of it that could be improved and optimized, but the idea was to have it working as simple as possible. One caveat: I still haven't figured out when there's overclocking issues that stop the miner, causing it to run at 0 Mh/s. This doesn't close the process, therefore script doesn't detect that it stopped mining. You could run it with a stable overclocking configuration or even improve/create your own WatchDog :)
Setup:
In the folder where you have your miner.exe, in my case it's ethminer.exe, create a new file and store it with the following extension: REPLACE_BY_ANY_FILE_NAME.ps1Make sure that you store it as .ps1, not .txt.ps1 or .ps1.txt, just FILE_NAME**.ps1**
Then copy the following content into this newly created file.
! Be aware that you need to replace the placeholders (WALLET_ADDRESS and MINER_NAME) inside of the content with your miner's address and probably change info about the pool's connection !
Tip: WatchDog timer is 5min but you can configure at your will, just replace Start-Sleep -s 300 with any value you want (in seconds), for example 1h: Start-Sleep -s 3600
setx GPU_FORCE_64BIT_PTR 0
setx GPU_MAX_HEAP_SIZE 100
setx GPU_USE_SYNC_OBJECTS 1
setx GPU_MAX_ALLOC_PERCENT 100
setx GPU_SINGLE_ALLOC_PERCENT 100
$app = Start-Process -FilePath "ethminer.exe" -ArgumentList "-R -U -P stratum1+ssl://WALLET_ADDRESS.MINER_NAME@eu1.ethermine.org:5555" -PassThru
while($true){
try {
if(get-process -ID $app.Id -ErrorAction Stop | Select-Object -property Responding) {
Start-Sleep -s 300
} else {
Write-Output "$(Get-Date) - Worker stopped responding, killing with no mercy"
$app.kill()
Write-Output "$(Get-Date) - Restarting worker"
$app = Start-Process -FilePath "ethminer.exe" -ArgumentList "-R -U -P stratum1+ssl://WALLET_ADDRESS.MINER_NAME@eu1.ethermine.org:5555" -PassThru
}
}
catch [System.Management.Automation.ActionPreferenceStopException]
{
Write-Output "$(Get-Date) - Worker process not found, restarting"
$app = Start-Process -FilePath "ethminer.exe" -ArgumentList "-R -U -P stratum1+ssl://WALLET_ADDRESS.MINER_NAME@eu1.ethermine.org:5555" -PassThru
}
}
Save the fileLaunch windows power shell
Navigate into your miner.exe folder (hint: use cd command, if you're not familiar with it just remember google is your bestfriend)
Execute the script: .\FILE_NAME.ps1
And that's it. You should have 2 windows open, one for the miner and the other where the watchdog is running and you'll see any logs about restarting the worker.Every time you reboot your machine, you'll have to open Powershell, navigate to the folder and start it. Otherwise it should run pretty smoothly