Add log cleanup function (15-day deletion) and archive documentation
- Added cleanup_old_logs() function to app_v3_simplified.py - Deletes log.txt if older than 15 days at app startup - Sends notification to monitoring server when cleanup occurs - Archived all legacy modules and documentation to oldcode/ - Updated device_info.txt with correct IP (192.168.1.104) - All changes validated and tested
This commit is contained in:
178
oldcode/README.md
Normal file
178
oldcode/README.md
Normal file
@@ -0,0 +1,178 @@
|
||||
# Prezenta Work - Workplace Attendance & Traceability System
|
||||
|
||||
## Project Structure
|
||||
|
||||
### 📁 Main Application Files
|
||||
- **app.py** - Main application orchestrator (v3.0)
|
||||
- **config_settings.py** - Centralized configuration (points to 192.168.1.103)
|
||||
- **data/** - Local data storage (logs, device info, RFID tags)
|
||||
- **Files/** - Package repository and dependencies
|
||||
|
||||
### 🔧 Core Modules (Production Ready)
|
||||
- **api_routes_module.py** - Flask API endpoints and web interface
|
||||
- **logger_module.py** - Local and remote logging system
|
||||
- **device_module.py** - Device information management
|
||||
- **system_init_module.py** - System initialization and hardware checks
|
||||
- **dependencies_module.py** - Package management and verification
|
||||
- **commands_module.py** - Secure command execution with allowlist
|
||||
- **autoupdate_module.py** - Remote application updates
|
||||
- **connectivity_module.py** - Network connectivity monitoring
|
||||
- **rfid_module.py** - RFID reader initialization
|
||||
|
||||
### ✨ Enhancement Modules (v3.0)
|
||||
- **logger_batch_module.py** - Batch logging with 75% network reduction
|
||||
- **chrome_launcher_module.py** - Fullscreen Chrome UI launcher
|
||||
- **wifi_recovery_module.py** - Auto WiFi recovery on server disconnect
|
||||
|
||||
### 📚 Documentation & Old Code
|
||||
See `oldcode/` folder for:
|
||||
- Legacy code and configuration files
|
||||
- Complete architecture documentation
|
||||
- Refactoring guides and summaries
|
||||
- Setup and troubleshooting guides
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Run Application
|
||||
```bash
|
||||
cd /srv/prezenta_work
|
||||
python3 app.py
|
||||
```
|
||||
|
||||
### Configuration
|
||||
All settings are centralized in `config_settings.py`:
|
||||
- **Monitoring Server:** 192.168.1.103:80
|
||||
- **Flask Port:** 80
|
||||
- **RFID Devices:** Auto-detected (/dev/ttyS0, /dev/ttyAMA0, etc.)
|
||||
|
||||
### Environment Variables
|
||||
Override default settings:
|
||||
```bash
|
||||
export MONITORING_SERVER_HOST=192.168.1.100
|
||||
export FLASK_PORT=8080
|
||||
python3 app.py
|
||||
```
|
||||
|
||||
## Key Features
|
||||
|
||||
### 🚀 v3.0 Enhancements
|
||||
1. **Batch Logging (75% Network Reduction)**
|
||||
- Queues logs every 5 seconds or at 10 items
|
||||
- Deduplicates events within 3-second window
|
||||
- Single HTTP request vs 3-4 per second
|
||||
|
||||
2. **Chrome Fullscreen UI**
|
||||
- Auto-launches traceability web app
|
||||
- Fullscreen kiosk mode for workplace display
|
||||
- Optional auto-startup via systemd
|
||||
|
||||
3. **WiFi Auto-Recovery**
|
||||
- Monitors server connectivity (60-second ping)
|
||||
- Disables WiFi for 20 minutes on server loss
|
||||
- Auto-restarts WiFi and resumes operation
|
||||
|
||||
## System Requirements
|
||||
|
||||
- **OS:** Raspberry Pi OS / Linux
|
||||
- **Python:** 3.7+
|
||||
- **Ports:** 80 (Flask web server)
|
||||
- **Hardware:** RFID reader, GPIO LEDs, WiFi interface
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All endpoints available at `http://192.168.1.103:80`
|
||||
|
||||
### GET /status
|
||||
Device status, uptime, disk usage, memory
|
||||
|
||||
### POST /logs
|
||||
Log submission endpoint (batch supported)
|
||||
|
||||
### POST /execute_command
|
||||
Execute pre-approved system commands
|
||||
|
||||
### POST /auto_update
|
||||
Check and apply remote updates
|
||||
|
||||
## Monitoring & Logs
|
||||
|
||||
### Local Logs
|
||||
```bash
|
||||
tail -f data/log.txt
|
||||
```
|
||||
|
||||
### Remote Server
|
||||
```bash
|
||||
curl http://192.168.1.103/status
|
||||
```
|
||||
|
||||
## Git Workflow
|
||||
|
||||
### Current Status
|
||||
- **Branch:** dev (latest v3.0 enhancements)
|
||||
- **Remote:** Synced with origin/dev
|
||||
- **Latest Commit:** Configuration update (192.168.1.103)
|
||||
|
||||
### View History
|
||||
```bash
|
||||
git log --oneline -5
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### RFID Reader Not Detected
|
||||
- Check `/dev/ttyS0`, `/dev/ttyAMA0`, `/dev/ttyUSB0`, `/dev/ttyACM0`
|
||||
- Verify UART is enabled on Raspberry Pi
|
||||
- Check GPIO permissions
|
||||
|
||||
### WiFi Recovery Not Working
|
||||
- Verify sudo permissions for `ip link set` commands
|
||||
- Check if ping destination is reachable
|
||||
- Review logs for recovery messages
|
||||
|
||||
### Batch Logging Issues
|
||||
- Check network connectivity to 192.168.1.103
|
||||
- Verify port 80 is open and Flask is running
|
||||
- Monitor batch queue in logs
|
||||
|
||||
## Development Notes
|
||||
|
||||
### Adding New Modules
|
||||
1. Create module in main directory
|
||||
2. Import in app.py
|
||||
3. Initialize in main() function
|
||||
4. Test and commit
|
||||
|
||||
### Modifying Configuration
|
||||
1. Edit config_settings.py
|
||||
2. Changes take effect on next restart
|
||||
3. Environment variables can override settings
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
# Syntax check
|
||||
python3 -m py_compile *.py
|
||||
|
||||
# Import test
|
||||
python3 -c "import app; print('✓ OK')"
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
For detailed documentation, see `oldcode/` folder:
|
||||
- MODULAR_ARCHITECTURE.md - Complete technical guide
|
||||
- QUICKSTART.md - API reference
|
||||
- DEPLOYMENT_CHECKLIST.md - Testing guide
|
||||
|
||||
## Version History
|
||||
|
||||
- **v3.0** - Enhanced with batch logging, Chrome UI, WiFi recovery
|
||||
- **v2.8** - Performance optimization (skip dependency checks)
|
||||
- **v2.7** - Fixed auto-update for case-sensitive systems
|
||||
- **v2.0+** - Modular architecture implementation
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** December 18, 2025
|
||||
**Status:** Production Ready (dev branch)
|
||||
**Monitoring Server:** 192.168.1.103:80
|
||||
Reference in New Issue
Block a user