Build [v1.14.22]
This commit is contained in:
@@ -344,6 +344,35 @@ def action_stop(backend_port: int, frontend_port: int, network_cfg: Dict[str, An
|
||||
|
||||
logger.info("Stopped.")
|
||||
|
||||
def generate_network_json(network_cfg: Dict[str, Any]):
|
||||
"""Sync network.yaml settings to frontend/public/network.json for runtime discovery."""
|
||||
server_ip = network_cfg.get("application", {}).get("server_ip", "localhost")
|
||||
ports = network_cfg.get("ports", {})
|
||||
|
||||
network_json = {
|
||||
"SERVER_IP": server_ip,
|
||||
"BACKEND_PORT": ports.get("backend_port", 8916),
|
||||
"BACKEND_SSL_PORT": ports.get("backend_ssl_port", 8918),
|
||||
"FRONTEND_PORT": ports.get("frontend_port", 8917),
|
||||
"FRONTEND_SSL_PORT": ports.get("frontend_ssl_port", 8919)
|
||||
}
|
||||
|
||||
# Try to find the frontend/public directory
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
public_dir = os.path.join(project_root, "frontend", "public")
|
||||
|
||||
if os.path.isdir(public_dir):
|
||||
target_path = os.path.join(public_dir, "network.json")
|
||||
try:
|
||||
import json
|
||||
with open(target_path, 'w') as f:
|
||||
json.dump(network_json, f, indent=2)
|
||||
logger.info(f"Generated {target_path} from network.yaml")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to generate network.json: {e}")
|
||||
else:
|
||||
logger.warning(f"Frontend public directory not found at {public_dir}. Skipping network.json generation.")
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="TFM aInventory Standalone Launcher")
|
||||
parser.add_argument("action", nargs="?", choices=["start", "stop", "restart", "status", "run"], default="run",
|
||||
@@ -380,6 +409,9 @@ def main():
|
||||
if args.action in ["start", "run"]:
|
||||
background = (args.action == "start")
|
||||
|
||||
# Generate network.json for frontend discovery before starting anything
|
||||
generate_network_json(network_cfg)
|
||||
|
||||
if not args.frontend_only:
|
||||
if is_port_in_use(backend_port):
|
||||
logger.error(f"Port {backend_port} is already in use. Backend cannot start.")
|
||||
|
||||
Reference in New Issue
Block a user