Compare commits
2 Commits
ee59511e5d
...
51d6fa568d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51d6fa568d | ||
|
|
72a9804c69 |
@@ -281,17 +281,13 @@ def main_rotation_cycle():
|
|||||||
|
|
||||||
logger.info("Starting nexus rotation cycle")
|
logger.info("Starting nexus rotation cycle")
|
||||||
|
|
||||||
while True:
|
|
||||||
cycle_count += 1
|
|
||||||
logger.info(f"=== Starting cycle #{cycle_count} ===")
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Get next node
|
# Get next node
|
||||||
node = get_next_node(grist, logger)
|
node = get_next_node(grist, logger)
|
||||||
if not node:
|
if not node:
|
||||||
logger.error("No node available, waiting 60 seconds before retry")
|
logger.error("No node available, waiting 60 seconds before retry")
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
continue
|
return
|
||||||
|
|
||||||
node_id = node.NodeID
|
node_id = node.NodeID
|
||||||
current_hours = int(node.Hours)
|
current_hours = int(node.Hours)
|
||||||
@@ -311,7 +307,7 @@ def main_rotation_cycle():
|
|||||||
grist.update(node.id, {"Hours": current_hours}, "Nodes")
|
grist.update(node.id, {"Hours": current_hours}, "Nodes")
|
||||||
logger.info(f"Reverted node {node_id} hours back to: {current_hours}")
|
logger.info(f"Reverted node {node_id} hours back to: {current_hours}")
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
continue
|
return
|
||||||
|
|
||||||
logger.info(f"Container started successfully for node {node_id}")
|
logger.info(f"Container started successfully for node {node_id}")
|
||||||
|
|
||||||
@@ -348,7 +344,7 @@ def main_rotation_cycle():
|
|||||||
# If container failed during the cycle, skip to next iteration
|
# If container failed during the cycle, skip to next iteration
|
||||||
if container_failed:
|
if container_failed:
|
||||||
logger.error(f"Container failed during cycle for node {node_id}, moving to next node")
|
logger.error(f"Container failed during cycle for node {node_id}, moving to next node")
|
||||||
continue
|
return
|
||||||
|
|
||||||
# Stop and remove container
|
# Stop and remove container
|
||||||
logger.info(f"5 hours completed for node {node_id}, stopping container")
|
logger.info(f"5 hours completed for node {node_id}, stopping container")
|
||||||
@@ -361,17 +357,7 @@ def main_rotation_cycle():
|
|||||||
|
|
||||||
logger.info(f"=== Cycle #{cycle_count} completed for node {node_id} ===")
|
logger.info(f"=== Cycle #{cycle_count} completed for node {node_id} ===")
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
logger.info("Received keyboard interrupt, stopping rotation")
|
|
||||||
stop_and_remove_container(container_name, logger)
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Cycle #{cycle_count} failed with error: {str(e)}")
|
|
||||||
stop_and_remove_container(container_name, logger)
|
|
||||||
logger.info("Waiting 60 seconds before next attempt")
|
|
||||||
time.sleep(60)
|
|
||||||
|
|
||||||
logger.info("Nexus rotation cycle stopped")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -5,3 +5,6 @@ curl https://gitea.vvzvlad.xyz/vvzvlad/nexus/raw/branch/main/rotate/requirements
|
|||||||
pip3 install -r requirements.txt --break-system-packages;
|
pip3 install -r requirements.txt --break-system-packages;
|
||||||
docker pull nexusxyz/nexus-cli:latest
|
docker pull nexusxyz/nexus-cli:latest
|
||||||
screen -S rotate -m python3 rotate.py
|
screen -S rotate -m python3 rotate.py
|
||||||
|
|
||||||
|
|
||||||
|
curl https://gitea.vvzvlad.xyz/vvzvlad/nexus/raw/branch/main/rotate/rotate.py?token=7b58d730732f07e90a88169a63531d96bfc0fbbd -o rotate.py; python3 rotate.py
|
||||||
Reference in New Issue
Block a user