From 07df07d1cb05781697ad89dc4e964f0667a36b99 Mon Sep 17 00:00:00 2001
From: chausman <chausman@nrao.edu>
Date: Thu, 18 May 2023 09:18:15 -0600
Subject: [PATCH] make sure CARTA opens only after setup finishes

---
 .../pexable/carta_envoy/carta_envoy/launchers.py          | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/apps/cli/executables/pexable/carta_envoy/carta_envoy/launchers.py b/apps/cli/executables/pexable/carta_envoy/carta_envoy/launchers.py
index 569345fb4..f66681748 100644
--- a/apps/cli/executables/pexable/carta_envoy/carta_envoy/launchers.py
+++ b/apps/cli/executables/pexable/carta_envoy/carta_envoy/launchers.py
@@ -22,6 +22,7 @@ import os
 import signal
 import subprocess
 import sys
+import time
 from http.server import HTTPServer, SimpleHTTPRequestHandler
 from pathlib import Path
 from threading import Thread
@@ -185,6 +186,11 @@ class CartaLauncher:
                 f"{file_browser_path!s}",
             ]
             try:
+                # finish setup for CARTA and ensure completion before launch
+                CartaWrapperLauncher.deploy_wrapper_html(file_browser_path, carta_url, session_timeout_date)
+                time.sleep(3)
+
+                #  start CARTA
                 CARTA_PROCESS = subprocess.Popen(
                     carta_command,
                     preexec_fn=os.setpgrp(),
@@ -196,7 +202,7 @@ class CartaLauncher:
                 self.teardown()
                 sys.exit(f"ERROR: Failed to launch CARTA: {err}")
             else:
-                CartaWrapperLauncher.deploy_wrapper_html(file_browser_path, carta_url, session_timeout_date)
+                # CartaWrapperLauncher.deploy_wrapper_html(file_browser_path, carta_url, session_timeout_date)
 
                 # CARTA is running and accessible, so send CARTA URL to AAT system or notify user
                 self.notify_ready(wrapper_url)
-- 
GitLab