Skip to content

Commit

Permalink
Add env var
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCoderCarl committed Apr 23, 2024
1 parent 1180f3f commit 76efc0d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
SETTINGS_FILE_FOR_DYNACONF: "/opt/settings.toml"
VERBOSE: "True"
ALERTING: "True"
ENVIRONMENT: "Dev"
# CHANEL: "TODO"
networks:
- chief_intelligence_officer
Expand Down
7 changes: 7 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
except KeyError as key_err:
logging.warning(f"Key Error - {key_err}")

try:
ENVIRONMENT = os.getenv("ENVIRONMENT")
if ENVIRONMENT:
logger.info(f"Environment is set to {ENVIRONMENT} !")
except KeyError as key_err:
logging.warning(f"Key Error - {key_err}")


def load_config(host_type: str) -> list:
"""
Expand Down
5 changes: 3 additions & 2 deletions src/telegram_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
logging.warning(f"Key Error - {key_err}")


def send_alert_to_telegram(message):
def send_alert_to_telegram(message, environment: str):
"""
Send messages alerts to telegram
:param environment:
:param message:
:return:
"""
Expand All @@ -45,7 +46,7 @@ def send_alert_to_telegram(message):
API_URL,
json={
"chat_id": CHAT_ID,
"text": f"{message}",
"text": f"Environment: {environment} \n {message}",
},
)
if response.status_code == 200:
Expand Down

0 comments on commit 76efc0d

Please sign in to comment.