Docker buid issue
This commit is contained in:
@ -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
|
||||
|
||||
@ -5,4 +5,5 @@ python-dotenv
|
||||
pymysql
|
||||
gunicorn
|
||||
cryptography
|
||||
pyserial
|
||||
pyserial
|
||||
PyJWT
|
||||
Reference in New Issue
Block a user