mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 07:48:26 -04:00
fix api health
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import ssl
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
@@ -7,10 +8,18 @@ from requests.exceptions import RequestException
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_no_x509_strict_context():
|
||||||
|
context = ssl.create_default_context()
|
||||||
|
context.options |= ssl.OP_NO_X509_STRICT
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
def is_api_down():
|
def is_api_down():
|
||||||
api_base_url = os.getenv("API_HOST_NAME")
|
api_base_url = os.getenv("API_HOST_NAME")
|
||||||
try:
|
try:
|
||||||
response = requests.get(api_base_url, timeout=2)
|
response = requests.get(
|
||||||
|
api_base_url, timeout=2, cert=get_no_x509_strict_context()
|
||||||
|
)
|
||||||
is_down = response.status_code != 200
|
is_down = response.status_code != 200
|
||||||
if is_down:
|
if is_down:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user