improve start_browser

- make it executable
- try again within 30 seconds
This commit is contained in:
2025-10-14 17:18:54 +02:00
parent 8a4dc7b50c
commit 382ecf67aa

15
start_browser.py Normal file → Executable file
View File

@@ -1,17 +1,26 @@
#!/usr/bin/python
import os
import sys
import time
import socket
show = True
starttime = time.time()
sys.stderr.write('start\n')
for _ in range(30):
try:
socket.create_connection(('localhost', 8010), timeout=1)
socket.create_connection(('localhost', 8080), timeout=1)
os.system('/usr/bin/chromium-browser http://localhost:8080/')
break
t = time.time() - starttime
if t > 30:
break
sys.stderr.write(f'{t:.3f} try again\n')
except Exception as e:
time.sleep(1)
t = time.time() - starttime
sys.stderr.write(f'{t:.3f} failed {e!r}\n')
if show:
print('waiting for frappy websocket')
show = False
time.sleep(1)
else:
print('do not start chrome - waiting for frappy websocket failed')