From 230f28d54e5d8015d6252f6193f113f68684f5b2 Mon Sep 17 00:00:00 2001 From: aserper Date: Fri, 12 Dec 2025 23:59:03 -0500 Subject: [PATCH] Fix container logging visibility Changes: - Add -u flag to Python in Dockerfile to disable output buffering - Add startup messages in main.py showing bot configuration - Logs now appear immediately in kubectl logs output This fixes the issue where no logs were visible when running in Kubernetes pods due to Python's default stdout buffering. --- Dockerfile | 4 ++-- main.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c10a348..cbdbf74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,5 +14,5 @@ RUN pip install --no-cache-dir -r requirements.txt # Copy the application code COPY . /app -# Run Python script -CMD ["python", "main.py"] +# Run Python script with unbuffered output for container logs +CMD ["python", "-u", "main.py"] diff --git a/main.py b/main.py index bc2e28d..c0287f5 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,8 @@ from bot import MastodonRSSBot def main(): """Initialize and run the bot with environment configuration""" + print("Starting Mastodon RSS Bot...") + # Load configuration from environment variables bot = MastodonRSSBot( client_id=os.environ["MASTODON_CLIENT_ID"], @@ -20,6 +22,16 @@ def main(): ), ) + print(f"Bot configured successfully:") + print(f" Instance: {os.environ['MASTODON_INSTANCE_URL']}") + print(f" Feed URL: {os.environ['RSS_FEED_URL']}") + print(f" Visibility: {os.environ.get('TOOT_VISIBILITY', 'public')}") + print(f" Check interval: {os.environ.get('CHECK_INTERVAL', '300')} seconds") + print( + f" State file: {os.environ.get('PROCESSED_ENTRIES_FILE', '/state/processed_entries.txt')}" + ) + print() + # Start the bot bot.run()