Made Agent more Graceful
This commit is contained in:
parent
119507a4ad
commit
c4ce9a6bd1
@ -133,6 +133,7 @@ def stop_all_roles():
|
|||||||
running_roles.clear()
|
running_roles.clear()
|
||||||
running_threads.clear()
|
running_threads.clear()
|
||||||
|
|
||||||
|
|
||||||
def start_role_thread(role_cfg):
|
def start_role_thread(role_cfg):
|
||||||
role = role_cfg.get("role")
|
role = role_cfg.get("role")
|
||||||
node_id = role_cfg.get("node_id")
|
node_id = role_cfg.get("node_id")
|
||||||
@ -194,5 +195,13 @@ def run_screenshot_loop(node_id, cfg):
|
|||||||
# ---------------- Main ----------------
|
# ---------------- Main ----------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app_instance = QtWidgets.QApplication(sys.argv)
|
app_instance = QtWidgets.QApplication(sys.argv)
|
||||||
sio.connect(SERVER_URL, transports=["websocket"])
|
retry_interval = 5 # seconds between connection attempts
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
print(f"[WebSocket] Connecting to {SERVER_URL}...")
|
||||||
|
sio.connect(SERVER_URL, transports=["websocket"]())
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[WebSocket] Borealis Server is Not Running - Retrying in {retry_interval} seconds...")
|
||||||
|
time.sleep(retry_interval)
|
||||||
sys.exit(app_instance.exec_())
|
sys.exit(app_instance.exec_())
|
||||||
|
@ -133,7 +133,7 @@ switch ($choice) {
|
|||||||
#>
|
#>
|
||||||
Run-Step "Install Python Dependencies into Virtual Python Environment" {
|
Run-Step "Install Python Dependencies into Virtual Python Environment" {
|
||||||
if (Test-Path "$dataSource\Server\server-requirements.txt") {
|
if (Test-Path "$dataSource\Server\server-requirements.txt") {
|
||||||
& $venvPython -m pip install -q -r "$dataSource\Server\server-requirements.txt" | Out-Null
|
& $venvPython -m pip install --disable-pip-version-check -q -r "$dataSource\Server\server-requirements.txt" | Out-Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,20 +217,15 @@ switch ($choice) {
|
|||||||
#>
|
#>
|
||||||
Run-Step "Install Python Dependencies for Agent" {
|
Run-Step "Install Python Dependencies for Agent" {
|
||||||
if (Test-Path $agentRequirements) {
|
if (Test-Path $agentRequirements) {
|
||||||
& $venvPython -m pip install -q -r $agentRequirements | Out-Null
|
& $venvPython -m pip install --disable-pip-version-check -q -r $agentRequirements | Out-Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
|
||||||
Step: Launch Agent
|
|
||||||
#>
|
|
||||||
Run-Step "Launch Borealis Agent" {
|
|
||||||
Write-Host "`nLaunching Borealis Agent..." -ForegroundColor Blue
|
Write-Host "`nLaunching Borealis Agent..." -ForegroundColor Blue
|
||||||
Write-Host "===================================================================================="
|
Write-Host "===================================================================================="
|
||||||
# call python with the absolute interpreter path and the absolute script path
|
# call python with the absolute interpreter path and the absolute script path
|
||||||
$agentScript = Join-Path $scriptDir $agentDestinationFile
|
$agentScript = Join-Path $scriptDir $agentDestinationFile
|
||||||
& $venvPython $agentScript
|
& $venvPython -W ignore::SyntaxWarning $agentScript
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
|
@ -97,7 +97,7 @@ launch_server() {
|
|||||||
source "${venvFolder}/bin/activate"
|
source "${venvFolder}/bin/activate"
|
||||||
|
|
||||||
run_step "Install Python Dependencies" bash -c "
|
run_step "Install Python Dependencies" bash -c "
|
||||||
pip install -q -r '${dataSource}/server-requirements.txt'
|
pip install --disable-pip-version-check -q -r '${dataSource}/server-requirements.txt'
|
||||||
"
|
"
|
||||||
|
|
||||||
run_step "Install React Dependencies" bash -c "
|
run_step "Install React Dependencies" bash -c "
|
||||||
@ -143,7 +143,7 @@ launch_agent() {
|
|||||||
source "${venvFolder}/bin/activate"
|
source "${venvFolder}/bin/activate"
|
||||||
|
|
||||||
run_step "Install Python Dependencies for Agent" bash -c "
|
run_step "Install Python Dependencies for Agent" bash -c "
|
||||||
pip install -q -r '${agentRequirements}'
|
pip install --disable-pip-version-check -q -r '${agentRequirements}'
|
||||||
"
|
"
|
||||||
|
|
||||||
echo -e "\n${GREEN}Launching Borealis Agent...${RESET}"
|
echo -e "\n${GREEN}Launching Borealis Agent...${RESET}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user