From 09bb67d904c64a305de62aebeae95d62af312c69 Mon Sep 17 00:00:00 2001 From: caryoscelus Date: Thu, 8 Sep 2022 12:06:48 +0000 Subject: [PATCH] keep browser process alive --- src/main.py | 9 +++++---- src/util/helper.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index 47701b99..22927955 100644 --- a/src/main.py +++ b/src/main.py @@ -66,12 +66,13 @@ except: if config.action == "main": from util import helper try: - lock = helper.openLocked("%s/lock.pid" % config.data_dir, "w") - lock.write("%s" % os.getpid()) + lock = helper.openLocked(f"{config.data_dir}/lock.pid", "w") + lock.write(f"{os.getpid()}") except BlockingIOError as err: startupError(f"Can't open lock file, your 0net client is probably already running, exiting... ({err})") - helper.openBrowser(config.open_browser) - sys.exit() + proc = helper.openBrowser(config.open_browser) + r = proc.wait() + sys.exit(r) config.initLogging() diff --git a/src/util/helper.py b/src/util/helper.py index fa979864..ac330fd8 100644 --- a/src/util/helper.py +++ b/src/util/helper.py @@ -362,6 +362,6 @@ def openBrowser(agent): url = f'http://{ui_ip}:{config.ui_port}/{config.homepage}' try: import subprocess - subprocess.Popen([config.open_browser, url]) + return subprocess.Popen([config.open_browser, url]) except Exception as err: print(f"Error starting browser: {err}")