Ver código fonte

fix docker tz issue

tuanchris 4 meses atrás
pai
commit
8fbfc585b1
2 arquivos alterados com 11 adições e 6 exclusões
  1. 1 1
      docker-compose.yml
  2. 10 5
      modules/core/pattern_manager.py

+ 1 - 1
docker-compose.yml

@@ -8,7 +8,7 @@ services:
     volumes:
       - .:/app
       # Mount timezone file from host for Still Sands scheduling
-      - /etc/timezone:/etc/timezone:ro
+      - /etc/timezone:/etc/host-timezone:ro
     devices:
       - "/dev/ttyACM0:/dev/ttyACM0"
     privileged: true

+ 10 - 5
modules/core/pattern_manager.py

@@ -46,20 +46,25 @@ def _get_system_timezone():
 
     user_tz = 'UTC'  # Default fallback
 
-    # Try to read timezone from /etc/timezone (mounted from host)
+    # Try to read timezone from /etc/host-timezone (mounted from host)
     try:
-        if os.path.exists('/etc/timezone'):
+        if os.path.exists('/etc/host-timezone'):
+            with open('/etc/host-timezone', 'r') as f:
+                user_tz = f.read().strip()
+                logger.info(f"Still Sands using timezone: {user_tz} (from host system)")
+        # Fallback to /etc/timezone if host-timezone doesn't exist
+        elif os.path.exists('/etc/timezone'):
             with open('/etc/timezone', 'r') as f:
                 user_tz = f.read().strip()
-                logger.info(f"Still Sands using timezone: {user_tz} (from system)")
-        # Fallback to TZ environment variable if /etc/timezone doesn't exist
+                logger.info(f"Still Sands using timezone: {user_tz} (from container)")
+        # Fallback to TZ environment variable
         elif os.environ.get('TZ'):
             user_tz = os.environ.get('TZ')
             logger.info(f"Still Sands using timezone: {user_tz} (from environment)")
         else:
             logger.info("Still Sands using timezone: UTC (default)")
     except Exception as e:
-        logger.debug(f"Could not read /etc/timezone: {e}")
+        logger.debug(f"Could not read timezone: {e}")
 
     # Cache the timezone
     _cached_timezone = user_tz