From 6b867f07433a8be9e16c4b41aac18e0912c863c7 Mon Sep 17 00:00:00 2001 From: zhaojing1987 Date: Thu, 16 May 2024 08:17:26 +0800 Subject: [PATCH] update apphub --- apphub/src/config/config.ini | 12 ++++++------ apphub/src/services/app_manager.py | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/apphub/src/config/config.ini b/apphub/src/config/config.ini index e8407934..5a7d26a4 100755 --- a/apphub/src/config/config.ini +++ b/apphub/src/config/config.ini @@ -1,7 +1,7 @@ [nginx_proxy_manager] base_url = http://websoft9-proxy:81/api -user_name = help@websoft9.com -user_pwd = JB21x6AkBshLRK5Y +user_name = admin@mydomain.com +user_pwd = Csj18AHvtBWzuIFA nike_name = admin listen_port = 80 @@ -9,18 +9,18 @@ listen_port = 80 base_url = http://websoft9-git:3000/api/v1 user_name = websoft9 user_email = admin@mydomain.com -user_pwd = HZ4RYXr9ce6R +user_pwd = vcwIB64zPslu [portainer] base_url = http://websoft9-deployment:9000/api user_name = admin -user_pwd = BDMnVb)gqRKISzfH +user_pwd = L@BI75LJ7Shi7oLA [api_key] key = bd3d92e0f52e299d014c38f8aac7f730602a8a7a41adbee77eddf07b391b9d31 [domain] -wildcard_domain = +wildcard_domain = test.websoft9.cn [cockpit] port = 9000 @@ -29,5 +29,5 @@ port = 9000 keys = [favorite_apps] -keys = +keys = kibana diff --git a/apphub/src/services/app_manager.py b/apphub/src/services/app_manager.py index 1d9ce1a1..16451623 100755 --- a/apphub/src/services/app_manager.py +++ b/apphub/src/services/app_manager.py @@ -3,6 +3,7 @@ import json import os import shutil import random +import ipaddress from datetime import datetime from src.core.config import ConfigManager from src.core.envHelper import EnvHelper @@ -421,10 +422,23 @@ class AppManger: # Set the password to env file envHelper.set_value("W9_POWER_PASSWORD", PasswordGenerator.generate_strong_password()) + # Set the settings to env file + if settings: + for key, value in settings.items(): + envHelper.set_value(key, value) + # Verify the app is web app is_web_app = envHelper.get_value("W9_URL") - if is_web_app is not None: + url_with_port = envHelper.get_value("W9_URL_WITH_PORT") + if is_web_app is not None and url_with_port is not None: + try: + ipaddress.ip_address(domain_names[0]) + envHelper.set_value("W9_URL", domain_names[0] + ":" + envHelper.get_value("W9_HTTP_PORT_SET")) + except ValueError: + envHelper.set_value("W9_URL", domain_names[0]) + elif url_with_port is None: envHelper.set_value("W9_URL", domain_names[0]) + # validate is bind ip(proxy_enabled is false) # if not proxy_enabled: # envHelper.set_value("W9_URL", domain_names[0]) @@ -433,12 +447,7 @@ class AppManger: # replace_domain_name = replace_domain_name.replace(replace_domain_name.split(".")[0], app_id, 1) # domain_names[0] = replace_domain_name # envHelper.set_value("W9_URL", domain_names[0]) - - # Set the settings to env file - if settings: - for key, value in settings.items(): - envHelper.set_value(key, value) - + # Commit and push to remote repo self._init_local_repo_and_push_to_remote(app_tmp_dir_path,repo_url) except CustomException as e: