This commit is contained in:
qiaofeng1227 2023-05-16 16:49:30 +08:00
parent b7aea33be7
commit 65d23ffdb4
2 changed files with 18 additions and 21 deletions

View File

@ -10,7 +10,7 @@ COPY static ./static
COPY requirements.txt main.py ./ COPY requirements.txt main.py ./
RUN apt update RUN apt update
# Install supervisord # Install supervisords
RUN apt install -y supervisor RUN apt install -y supervisor
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/cmd.sh /cmd.sh COPY config/cmd.sh /cmd.sh

View File

@ -593,8 +593,9 @@ def app_domain_delete(app_id, domain):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
response = requests.delete(url, headers=headers) response = requests.delete(url, headers=headers)
if response.json()["error"] != None: myLogger.info_logger(response)
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") #if response.json()["error"] != None:
# raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
set_domain("", app_id) set_domain("", app_id)
else: else:
proxy_id = proxy["id"] proxy_id = proxy["id"]
@ -629,8 +630,9 @@ def app_domain_delete(app_id, domain):
} }
response = requests.put(url, data=json.dumps(data), headers=headers) response = requests.put(url, data=json.dumps(data), headers=headers)
if response.json()["error"] != None: myLogger.info_logger(response)
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") #if response.json()["error"] != None:
# raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
domain_set = app_domain_list(app_id) domain_set = app_domain_list(app_id)
default_domain = domain_set['default_domain'] default_domain = domain_set['default_domain']
# 如果被删除的域名是默认域名,删除后去剩下域名的第一个 # 如果被删除的域名是默认域名,删除后去剩下域名的第一个
@ -696,8 +698,7 @@ def app_domain_update(app_id, domain_old, domain_new):
} }
response = requests.put(url, data=json.dumps(data), headers=headers) response = requests.put(url, data=json.dumps(data), headers=headers)
if response.json()["error"] != None: myLogger.info_logger(response)
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
domain_set = app_domain_list(app_id) domain_set = app_domain_list(app_id)
default_domain = domain_set['default_domain'] default_domain = domain_set['default_domain']
# 如果被修改的域名是默认域名,修改后也设置为默认域名 # 如果被修改的域名是默认域名,修改后也设置为默认域名
@ -762,10 +763,10 @@ def app_domain_add(app_id, domain):
"hsts_subdomains": False, "hsts_subdomains": False,
"ssl_forced": False "ssl_forced": False
} }
myLogger.info_logger(data)
response = requests.put(url, data=json.dumps(data), headers=headers) response = requests.put(url, data=json.dumps(data), headers=headers)
if response.json()["error"] != None: myLogger.info_logger(response)
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") #if response.json()["error"] != None:
# raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
else: else:
# 追加 # 追加
token = get_token() token = get_token()
@ -801,9 +802,9 @@ def app_domain_add(app_id, domain):
response = requests.post(url, data=json.dumps(data), headers=headers) response = requests.post(url, data=json.dumps(data), headers=headers)
myLogger.info_logger(response) myLogger.info_logger(response)
if response.json()["error"]: #if response.json()["error"]:
myLogger.info_logger(response.json()) # myLogger.info_logger(response.json())
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "") # raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
set_domain(domain, app_id) set_domain(domain, app_id)
return domain return domain
@ -857,8 +858,7 @@ def get_token():
"secret": password "secret": password
} }
response = requests.post(url, data=json.dumps(param), headers=headers) response = requests.post(url, data=json.dumps(param), headers=headers)
if response["error"] != None:
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
token = "Bearer " + response.json()["token"] token = "Bearer " + response.json()["token"]
return token return token
@ -872,8 +872,7 @@ def get_proxy(app_id):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)
if response.json()["error"] != None:
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
for proxy in response.json(): for proxy in response.json():
portainer_name = proxy["forward_host"] portainer_name = proxy["forward_host"]
if customer_name == portainer_name: if customer_name == portainer_name:
@ -892,8 +891,7 @@ def get_proxy_domain(app_id, domain):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)
if response.json()["error"] != None:
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
myLogger.info_logger(response.json()) myLogger.info_logger(response.json())
for proxy in response.json(): for proxy in response.json():
portainer_name = proxy["forward_host"] portainer_name = proxy["forward_host"]
@ -917,8 +915,7 @@ def get_all_domains(app_id):
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)
if response.json()["error"] != None:
raise CommandException(const.ERROR_API_NGINX, response.json()["error"]["message"], "")
for proxy in response.json(): for proxy in response.json():
portainer_name = proxy["forward_host"] portainer_name = proxy["forward_host"]
if customer_name == portainer_name: if customer_name == portainer_name: