mirror of
https://github.com/Death916/minestart.git
synced 2026-04-10 03:33:43 -07:00
finished kill miner and edited main loop
This commit is contained in:
parent
e4861c0272
commit
2e2740e008
1 changed files with 18 additions and 5 deletions
23
minestart.py
23
minestart.py
|
|
@ -5,6 +5,7 @@ import GPUtil as gpu
|
||||||
import time
|
import time
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
|
|
||||||
def checkgpu():
|
def checkgpu():
|
||||||
card = gpu.getGPUs()
|
card = gpu.getGPUs()
|
||||||
isavailable = gpu.getAvailability(card, maxLoad=.6)
|
isavailable = gpu.getAvailability(card, maxLoad=.6)
|
||||||
|
|
@ -16,9 +17,9 @@ def checkgpu():
|
||||||
|
|
||||||
if isavailable == [0]:
|
if isavailable == [0]:
|
||||||
print("cant mine")
|
print("cant mine")
|
||||||
time.sleep(5)
|
time.sleep(500)
|
||||||
return 'notavailable'
|
|
||||||
|
|
||||||
|
return 'notavailable'
|
||||||
|
|
||||||
|
|
||||||
def findProcessIdByName(processName):
|
def findProcessIdByName(processName):
|
||||||
|
|
@ -35,7 +36,7 @@ def findProcessIdByName(processName):
|
||||||
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return listOfProcessObjects;
|
return listOfProcessObjects
|
||||||
|
|
||||||
|
|
||||||
def checkminer():
|
def checkminer():
|
||||||
|
|
@ -45,6 +46,14 @@ def checkminer():
|
||||||
else:
|
else:
|
||||||
return "running"
|
return "running"
|
||||||
|
|
||||||
|
def killminer():
|
||||||
|
miner = findProcessIdByName('ccminer.exe')
|
||||||
|
pid = miner[0]['pid']
|
||||||
|
psutil.Process(pid).kill()
|
||||||
|
print('killed miner')
|
||||||
|
|
||||||
|
def startminer():
|
||||||
|
psutil.Popen(['E:\downloads\ccminer.bat'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,8 +62,12 @@ while True:
|
||||||
miner = checkminer()
|
miner = checkminer()
|
||||||
if gpus is 'isavailable' and miner is 'notrunning':
|
if gpus is 'isavailable' and miner is 'notrunning':
|
||||||
print('can start miner')
|
print('can start miner')
|
||||||
else:
|
startminer()
|
||||||
print('cant start miner')
|
time.sleep(30)
|
||||||
|
if gpus is 'isavailable' and miner is 'running':
|
||||||
|
killminer()
|
||||||
|
#kill miner
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue