Commit 4e7cc0a6 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Check server is OK before launching browser, Fixes #118

parent b2860602
......@@ -8,6 +8,8 @@ from glob import glob
import time
from dgenies.config_reader import AppConfigReader
from dgenies.bin.clean_jobs import parse_data_folders, parse_database, parse_upload_folders
import requests
from requests.exceptions import ConnectionError
runned = False
......@@ -86,23 +88,39 @@ def parse_args():
return None, None
def start_browser(host, port):
print("Starting browser...")"http://{0}:{1}".format(host, port))
def start_browser(host, port, app):
web_url = "http://{0}:{1}".format(host, port)
status_code = -1
tries = 0
while status_code != 200 and tries < 60:
status_code = requests.get(web_url).status_code
except ConnectionError:
status_code = 500
if status_code != 200:
tries += 1
if app.got_first_request:
print("Starting browser...")
print("App has not started. Cancel run of browser")
def run(mode="standalone", debug=False, host="", port=5000, no_crons=False, no_browser=False):
os.environ['DISABLE_CRONS'] = "True" if no_crons else "False"
if not debug and not no_browser:
thread = threading.Timer(2, start_browser, kwargs={
"host": host,
"port": port
if debug:
os.environ['LOGS'] = "True"
from dgenies import launch
app = launch(mode=mode, debug=debug)
if not debug and not no_browser:
thread = threading.Timer(1, start_browser, kwargs={
"host": host,
"port": port,
"app": app
thread.start(), port=port, debug=debug)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment