Docker buid issue

This commit is contained in:
2025-10-17 11:32:24 +05:30
parent aa583013bc
commit f7550653c0
2 changed files with 16 additions and 11 deletions

View File

@ -65,16 +65,20 @@ def create_app():
db.create_all()
print(f"✓ Database initialized ({flask_env})")
# FIXED: Serial service connection BEFORE return
from app.services.services import serial_service
try:
connected = serial_service.connect_to_machine('/dev/ttyUSB0', 9600)
if connected:
print("✓ Vending machine connected successfully")
else:
print("✗ Failed to connect to vending machine")
except Exception as e:
print(f"Serial connection error: {e}")
# OPTIONAL: Serial service connection (non-blocking)
# Only attempt connection if ENABLE_SERIAL is set to true
if os.getenv('ENABLE_SERIAL', 'false').lower() == 'true':
from app.services.services import serial_service
try:
connected = serial_service.connect_to_machine('/dev/ttyUSB0', 9600)
if connected:
print("✓ Vending machine connected successfully")
else:
print("Vending machine not connected (device may not be available)")
except Exception as e:
print(f"⚠ Serial connection skipped: {e}")
else:
print(" Serial connection disabled (set ENABLE_SERIAL=true to enable)")
# Register blueprints
from app.routes.routes import bp