fix: Load current scheduled playlist on startup

The scheduler now loads the appropriate playlist immediately when the
server starts, not just at the next scheduled time. This ensures the
stream plays the correct time-based playlist right away.
This commit is contained in:
glenneth 2025-12-17 15:31:37 +03:00 committed by Brian O'Reilly
parent 6a80072075
commit e2e3dbfbe0
1 changed files with 6 additions and 1 deletions

View File

@ -246,12 +246,17 @@
;;; Auto-start scheduler when database is connected ;;; Auto-start scheduler when database is connected
;;; This ensures the scheduler starts after the server is fully initialized ;;; This ensures the scheduler starts after the server is fully initialized
(define-trigger db:connected :after () (define-trigger db:connected ()
"Start the playlist scheduler after database connection is established" "Start the playlist scheduler after database connection is established"
(format t "~&[SCHEDULER] Database connected, starting playlist scheduler...~%") (format t "~&[SCHEDULER] Database connected, starting playlist scheduler...~%")
(handler-case (handler-case
(progn (progn
(start-playlist-scheduler) (start-playlist-scheduler)
;; Load the current scheduled playlist on startup
(let ((current-playlist (get-current-scheduled-playlist)))
(when current-playlist
(format t "~&[SCHEDULER] Loading current scheduled playlist: ~a~%" current-playlist)
(load-scheduled-playlist current-playlist)))
(format t "~&[SCHEDULER] Scheduler auto-started successfully~%")) (format t "~&[SCHEDULER] Scheduler auto-started successfully~%"))
(error (e) (error (e)
(format t "~&[SCHEDULER] Warning: Could not auto-start scheduler: ~a~%" e)))) (format t "~&[SCHEDULER] Warning: Could not auto-start scheduler: ~a~%" e))))