JakobLichterfeld / TeslaMate-Telegram-Bot

A telegram bot which sends a message if an update for your Tesla is available (use TeslaMate MQTT)
MIT License
26 stars 4 forks source link

If environment variable validation fails, CPU usage is very high #36

Closed freinbichler closed 8 months ago

freinbichler commented 8 months ago

Today after updating to version 0.7.2 and 0.7.3, which caused issues #33 and #35, my server CPU usage was constantly at >90%. Probably there is an endless loop running trying to validate the config again and again. After I stopped the (broken) teslamatetelegrambot container, CPU usage returned to normal:

Screenshot 2024-03-21 at 13 43 11
JakobLichterfeld commented 8 months ago

Probably there is an endless loop running trying to validate the config again and again.

Yeah, no more releases for me after 3 hours sleep

JakobLichterfeld commented 8 months ago

I assume you have restart: unless-stopped in your docker-compose.yml config. This causes the container to restart on every exit beside of a docker compose stop. So its kind of expected behavior.

However Logs would indicate it:

teslamatetelegrambot-1 | 2024-03-21 13:48:17,000 - ERROR - Error: Please set the environment variable CAR_ID to a valid number and try again. teslamatetelegrambot-1 exited with code 1 teslamatetelegrambot-1 | 2024-03-21 13:48:17,521 - ERROR - Error: Please set the environment variable CAR_ID to a valid number and try again. teslamatetelegrambot-1 exited with code 1 teslamatetelegrambot-1 | 2024-03-21 13:48:18,184 - ERROR - Error: Please set the environment variable CAR_ID to a valid number and try again. teslamatetelegrambot-1 exited with code 1 teslamatetelegrambot-1 | 2024-03-21 13:48:19,060 - ERROR - Error: Please set the environment variable CAR_ID to a valid number and try again. teslamatetelegrambot-1 exited with code 1 teslamatetelegrambot-1 | 2024-03-21 13:48:20,357 - ERROR - Error: Please set the environment variable CAR_ID to a valid number and try again. teslamatetelegrambot-1 exited with code 1

freinbichler commented 8 months ago

True, I have restart: unless-stopped in my docker compose config. However, I do not see exited with code 1

teslamate-teslamatetelegrambot-1  | 2024-03-21 12:06:47,886 - INFO - Starting the Teslamate Telegram Bot.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:06:47,888 - INFO - Setting up the MQTT client...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:06:47,889 - INFO - Connect to MQTT broker at mosquitto:1883
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:06:48,135 - INFO - Setting up the Telegram bot...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:06:49,878 - ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:07:23,891 - INFO - Starting the Teslamate Telegram Bot.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:07:23,892 - INFO - Setting up the MQTT client...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:07:23,893 - INFO - Connect to MQTT broker at mosquitto:1883
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:07:24,643 - INFO - Setting up the Telegram bot...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:07:26,650 - ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:00,153 - INFO - Starting the Teslamate Telegram Bot.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:00,154 - INFO - Setting up the MQTT client...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:00,154 - INFO - Connect to MQTT broker at mosquitto:1883
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:00,398 - INFO - Setting up the Telegram bot...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:01,897 - ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:35,397 - INFO - Starting the Teslamate Telegram Bot.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:35,398 - INFO - Setting up the MQTT client...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:35,399 - INFO - Connect to MQTT broker at mosquitto:1883
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:35,647 - INFO - Setting up the Telegram bot...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:08:37,144 - ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:09:19,880 - INFO - Starting the Teslamate Telegram Bot.
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:09:19,880 - INFO - Setting up the MQTT client...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:09:19,881 - INFO - Connect to MQTT broker at mosquitto:1883
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:09:20,158 - INFO - Setting up the Telegram bot...
teslamate-teslamatetelegrambot-1  | 2024-03-21 12:09:23,387 - ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.
JakobLichterfeld commented 8 months ago

Will add a 2-Minute wait before exiting the python code