Phase 3 Step 6: Complete Scheduler Integration with Bug Fixes
Implemented complete scheduler integration with automatic schedule loading, orphaned scan cleanup, and conversion to local timezone for better UX. Backend Changes: - Added load_schedules_on_startup() to load enabled schedules on app start - Implemented cleanup_orphaned_scans() to handle crashed/interrupted scans - Converted scheduler from UTC to local system timezone throughout - Enhanced scheduler service with robust error handling and logging Frontend Changes: - Updated all schedule UI templates to display local time instead of UTC - Improved timezone indicators and user messaging - Removed confusing timezone converter (no longer needed) - Updated quick templates and help text for local time Bug Fixes: - Fixed critical timezone bug causing cron expressions to run at wrong times - Fixed orphaned scans stuck in 'running' status after system crashes - Improved time display clarity across all schedule pages All schedules now use local system time for intuitive scheduling.
This commit is contained in:
12
web/app.py
12
web/app.py
@@ -294,11 +294,23 @@ def init_scheduler(app: Flask) -> None:
|
||||
app: Flask application instance
|
||||
"""
|
||||
from web.services.scheduler_service import SchedulerService
|
||||
from web.services.scan_service import ScanService
|
||||
|
||||
# Create and initialize scheduler
|
||||
scheduler = SchedulerService()
|
||||
scheduler.init_scheduler(app)
|
||||
|
||||
# Perform startup tasks with app context for database access
|
||||
with app.app_context():
|
||||
# Clean up any orphaned scans from previous crashes/restarts
|
||||
scan_service = ScanService(app.db_session)
|
||||
orphaned_count = scan_service.cleanup_orphaned_scans()
|
||||
if orphaned_count > 0:
|
||||
app.logger.warning(f"Cleaned up {orphaned_count} orphaned scan(s) on startup")
|
||||
|
||||
# Load all enabled schedules from database
|
||||
scheduler.load_schedules_on_startup()
|
||||
|
||||
# Store in app context for access from routes
|
||||
app.scheduler = scheduler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user