prevent multiple miner screen sessions under HiveOS
This commit is contained in:
parent
20d3d9b6c8
commit
e71697cefa
|
@ -105,14 +105,19 @@ def hive_set_miner_status(enabled=False):
|
||||||
### control miner state - OFF/ON
|
### control miner state - OFF/ON
|
||||||
screen_out = run_command("screen -ls")
|
screen_out = run_command("screen -ls")
|
||||||
miner_screen_running = False
|
miner_screen_running = False
|
||||||
|
miner_screen_session_pids = []
|
||||||
if screen_out[0] == 0 or screen_out[0] == 1:
|
if screen_out[0] == 0 or screen_out[0] == 1:
|
||||||
screen_lines=screen_out[1].split('\n')
|
screen_lines=screen_out[1].split('\n')
|
||||||
for screen_line in screen_lines:
|
for screen_line in screen_lines:
|
||||||
screen_line_parts=screen_line.replace('\t', '', 1).split('\t')
|
screen_line_parts=screen_line.replace('\t', '', 1).split('\t')
|
||||||
if len(screen_line_parts)>2 and '.' in screen_line_parts[0]:
|
if len(screen_line_parts)>2 and '.' in screen_line_parts[0]:
|
||||||
if screen_line_parts[0].split('.',1)[1]=="miner":
|
if screen_line_parts[0].split('.',1)[1]=="miner":
|
||||||
|
miner_screen_session_pids.append(screen_line_parts[0].split('.',1)[0])
|
||||||
miner_screen_running=True
|
miner_screen_running=True
|
||||||
if miner_screen_running and not enabled:
|
if len(miner_screen_session_pids) > 1: ## Something really bad going on, destroy all instances
|
||||||
|
for idx, miner_screen_session_pid in enumerate(miner_screen_session_pids):
|
||||||
|
run_command(f"kill -9 {miner_screen_session_pid}{' && screen -wipe' if idx==len(miner_screen_session_pids)-1 else ''}")
|
||||||
|
elif miner_screen_running and not enabled:
|
||||||
run_command(f"/bin/bash -c \"PATH={HIVE_PATH} && sudo /hive/bin/miner stop\"")
|
run_command(f"/bin/bash -c \"PATH={HIVE_PATH} && sudo /hive/bin/miner stop\"")
|
||||||
elif enabled and not miner_screen_running:
|
elif enabled and not miner_screen_running:
|
||||||
run_command(f"/bin/bash -c \"PATH={HIVE_PATH} && sudo /hive/sbin/nvidia-oc && sudo /hive/bin/miner start\"")
|
run_command(f"/bin/bash -c \"PATH={HIVE_PATH} && sudo /hive/sbin/nvidia-oc && sudo /hive/bin/miner start\"")
|
||||||
|
|
Loading…
Reference in New Issue