From d6f90ab49773e5827727f4a67c6e8b8391c1cc68 Mon Sep 17 00:00:00 2001 From: clore Date: Sat, 5 Oct 2024 18:53:29 +0200 Subject: [PATCH] better hiveos miner integration support --- lib/hive_miner_interface.py | 2 +- lib/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hive_miner_interface.py b/lib/hive_miner_interface.py index fc0a4b0..60d0f68 100644 --- a/lib/hive_miner_interface.py +++ b/lib/hive_miner_interface.py @@ -69,7 +69,7 @@ async def get_session_start_time(pid): return None async def get_miner_stats(miner_dir, api_timeout=15): - stdout, stderr, code = await async_run_bash_command(f'export PATH=$PATH:/hive/sbin:/hive/bin && export API_TIMEOUT={api_timeout}'+''' && read -t $((API_TIMEOUT + 5)) -d "" pid khs stats < <(function run_miner_scripts { echo "$BASHPID"; cd '''+miner_dir+''' || exit; cd '''+miner_dir+'''; source h-manifest.conf; cd '''+miner_dir+'''; source h-config.sh; cd '''+miner_dir+'''; source h-stats.sh; printf "%q\n" "$khs"; echo "$stats"; }; run_miner_scripts) && [[ $? -ge 128 ]] && [[ ! -z "$pid" && "$pid" -ne $$ ]] && kill -9 "$pid" 2>/dev/null ; echo $stats''') + stdout, stderr, code = await async_run_bash_command(f'export PATH=$PATH:/hive/sbin:/hive/bin && export API_TIMEOUT={api_timeout}'+''' && read -t $((API_TIMEOUT + 5)) -d "" pid khs stats < <(function run_miner_scripts { echo "$BASHPID"; cd '''+miner_dir+''' || exit; cd '''+miner_dir+'''; source h-manifest.conf; cd '''+miner_dir+'''; source h-stats.sh; printf "%q\n" "$khs"; echo "$stats"; }; run_miner_scripts) && [[ $? -ge 128 ]] && [[ ! -z "$pid" && "$pid" -ne $$ ]] && kill -9 "$pid" 2>/dev/null ; echo $stats''') try: if stdout and not stderr and code == 0: stats = json.loads(stdout) diff --git a/lib/utils.py b/lib/utils.py index f38065d..91b0497 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -120,7 +120,7 @@ def hive_set_miner_status(enabled=False): elif miner_screen_running and not enabled: run_command(f"/bin/bash -c \"PATH={HIVE_PATH} && sudo /hive/bin/miner stop\"") 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 \"export PATH={HIVE_PATH} && sudo /hive/sbin/nvidia-oc && source ~/.bashrc ; sudo /hive/bin/miner start\"") def get_extra_allowed_images(): if os.path.exists(config.extra_allowed_images_file):