diff --git a/ui/src/linux/main.py b/ui/src/linux/main.py index 29858ad..682a853 100644 --- a/ui/src/linux/main.py +++ b/ui/src/linux/main.py @@ -32,6 +32,7 @@ def main(): reply = the_interface.settings() exit() + goldwarden.run_daemon_background(token) # start daemons dbus_autofill_monitor.run_daemon(token) # todo: remove after migration dbus_monitor.run_daemon(token) diff --git a/ui/src/services/goldwarden.py b/ui/src/services/goldwarden.py index ec29b7e..1d2eded 100644 --- a/ui/src/services/goldwarden.py +++ b/ui/src/services/goldwarden.py @@ -178,17 +178,16 @@ def run_daemon(token): print("starting goldwarden daemon", BINARY_PATH, token) # print while running - result = subprocess.Popen([f"{BINARY_PATH}", "daemonize"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=daemon_env) - if result.returncode != 0: - print("Failed err", result.stderr) - raise Exception("Failed to start daemon") + result = subprocess.Popen([f"{BINARY_PATH}", "daemonize"], stdout=subprocess.PIPE, text=True, env=daemon_env) - # log stdout and stderr to file - with open(f"{log_directory}/daemon.log", "w") as f: - f.write(result.stdout.read()) - f.write(result.stderr.read()) - - result.wait() + # write log to file until process exits + log_file = open(f"{log_directory}/daemon.log", "w") + while result.poll() == None: + # read stdout and stder + stdout = result.stdout.readline() + log_file.write(stdout) + log_file.flush() + log_file.close() print("quitting goldwarden daemon") return result.returncode