diff --git a/appmanage/Dockerfile b/appmanage/Dockerfile index d6cf741e..ef28a3a5 100644 --- a/appmanage/Dockerfile +++ b/appmanage/Dockerfile @@ -10,7 +10,7 @@ COPY static ./static COPY requirements.txt main.py ./ RUN apt update -# Install supervisords +# Install supervisord RUN apt install -y supervisor COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY config/cmd.sh /cmd.sh diff --git a/appmanage/api/service/manage.py b/appmanage/api/service/manage.py index 5aaeba57..d2b3b4df 100644 --- a/appmanage/api/service/manage.py +++ b/appmanage/api/service/manage.py @@ -593,10 +593,8 @@ def app_domain_delete(app_id, domain): 'Content-Type': 'application/json' } response = requests.delete(url, headers=headers) - myLogger.info_logger(response.json()) - myLogger.info_logger(response.json().get("error")) - if response.json().get("error") != None: - raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") + if response.json().get("error"): + raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") set_domain("", app_id) else: proxy_id = proxy["id"] @@ -631,9 +629,8 @@ def app_domain_delete(app_id, domain): } response = requests.put(url, data=json.dumps(data), headers=headers) - myLogger.info_logger(response) - #if response.json()["error"] != None: - # raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") + if response.json().get("error"): + raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") domain_set = app_domain_list(app_id) default_domain = domain_set['default_domain'] # 如果被删除的域名是默认域名,删除后去剩下域名的第一个 @@ -643,7 +640,6 @@ def app_domain_delete(app_id, domain): else: raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "Domain is not bind", "") - def app_domain_update(app_id, domain_old, domain_new): @@ -699,7 +695,8 @@ def app_domain_update(app_id, domain_old, domain_new): } response = requests.put(url, data=json.dumps(data), headers=headers) - myLogger.info_logger(response) + if response.json().get("error"): + raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") domain_set = app_domain_list(app_id) default_domain = domain_set['default_domain'] # 如果被修改的域名是默认域名,修改后也设置为默认域名 @@ -765,9 +762,8 @@ def app_domain_add(app_id, domain): "ssl_forced": False } response = requests.put(url, data=json.dumps(data), headers=headers) - myLogger.info_logger(response) - #if response.json()["error"] != None: - # raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") + if response.json().get("error"): + raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") else: # 追加 token = get_token() @@ -802,11 +798,9 @@ def app_domain_add(app_id, domain): } response = requests.post(url, data=json.dumps(data), headers=headers) - myLogger.info_logger(response.json()) - myLogger.info_logger(response.json().get("error")) - #if response.json()["error"]: - # myLogger.info_logger(response.json()) - # raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") + + if response.json().get("error"): + raise CommandException(const.ERROR_CONFIG_NGINX, response.json().get("error").get("message"), "") set_domain(domain, app_id) return domain diff --git a/appmanage/api/utils/const.py b/appmanage/api/utils/const.py index 97d6185c..24a9f830 100644 --- a/appmanage/api/utils/const.py +++ b/appmanage/api/utils/const.py @@ -5,7 +5,7 @@ ERROR_CLIENT_PARAM_BLANK="Client.Parameter.Blank.Error" ERROR_CLIENT_PARAM_Format="Client.Parameter.Format.Error" ERROR_CLIENT_PARAM_NOTEXIST="Client.Parameter.Value.NotExist.Error" ERROR_CLIENT_PARAM_REPEAT="Client.Parameter.Value.Repeat.Error" -ERROR_API_NGINX="Api.Nginx.Error" +ERROR_CONFIG_NGINX="Nginx.Configure.Error" ERROR_SERVER_COMMAND="Server.Container.Error" ERROR_SERVER_SYSTEM="Server.SystemError" ERROR_SERVER_RESOURCE="Server.ResourceError"