keep browser process alive

This commit is contained in:
caryoscelus 2022-09-08 12:06:48 +00:00
parent c5876b1a0d
commit 09bb67d904
2 changed files with 6 additions and 5 deletions

View file

@ -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()

View file

@ -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}")