Commit Graph

3 Commits

Author SHA1 Message Date
cproudlock
1feb508574 Feature: Add comprehensive debug logging to troubleshoot 500 errors
Added detailed debug logging throughout the application to diagnose
production issues on Windows Server with MySQL 5.6.

Debug Features:
- Enable with environment variable: DEBUG=true
- Logs database connection attempts with host, port, user, database
- Shows MySQL version on successful connection
- Tracks query execution step-by-step
- Reports row counts fetched from database
- Shows data conversion progress
- Categorization results (current vs upcoming events)
- All errors include error codes, SQL state, and full stack traces

Debug output includes:
- Connection parameters (host:port/database)
- MySQL server version
- Query execution status
- Number of rows returned
- Data conversion steps
- Event categorization counts

Startup now shows:
- DEBUG MODE: ENABLED/DISABLED
- Database connection info
- Instructions to enable debug mode

Error responses now include:
- Full error message
- Error code (errno)
- SQL state (if available)
- Complete stack trace

Usage on Windows production:
  set DEBUG=true
  python app.py

Or with PM2:
  pm2 delete shopfloor-dashboard
  pm2 start app.py --name shopfloor-dashboard --interpreter python3 --env DEBUG=true
  pm2 logs shopfloor-dashboard

This will help identify the exact cause of 500 errors without switching
to a different MySQL connector.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 13:46:49 -04:00
cproudlock
a92c2401dd Fix: Add MySQL 5.6 compatibility and detailed error logging
Added better error handling and MySQL 5.6 support for Windows Server:

1. Enhanced error logging in app.py:
   - Detailed database error messages with error codes
   - Full stack traces logged to console/PM2
   - Error details returned in JSON for debugging

2. Created app-pymysql.py:
   - Alternative version using PyMySQL instead of mysql-connector-python
   - Better compatibility with older MySQL 5.6 servers
   - Handles bit field conversion from bytes to boolean
   - Pure Python implementation (no C extensions)

3. Added requirements-mysql56.txt:
   - PyMySQL 1.1.0 for MySQL 5.6 compatibility
   - Use this on Windows servers with old MySQL

For production Windows servers with MySQL 5.6, use:
  pip install -r requirements-mysql56.txt
  python app-pymysql.py

For debugging 500 errors, check console/PM2 logs for detailed error messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 13:41:52 -04:00
cproudlock
fbe5312e7b Feature: Convert from Node.js/Express to Python/Flask
BREAKING CHANGE: Replaced Node.js backend with Python Flask

Reason: npm not available on production server, Python/pip is available.

Changes:
- Created app.py (Flask) to replace server.js (Node.js)
- Created requirements.txt with only 2 dependencies (Flask, mysql-connector-python)
- Updated README.md with Flask installation and deployment instructions
- Maintained all existing functionality:
  * Same API endpoints (/api/notifications, /health)
  * Same database queries (isshopfloor filter, 72-hour window)
  * Same priority sorting (incidents first)
  * Serves static files from public/ directory
  * Same environment variable configuration

Dependencies:
- Flask==3.0.0
- mysql-connector-python==8.2.0

The public/index.html frontend remains unchanged - only the backend was converted.

Tested and verified:
- API endpoint returns correct data
- Health check responds
- Dashboard displays properly
- Database connectivity working
- PM2 process manager compatible

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 11:52:34 -04:00