diff --git a/src/main.lisp b/src/main.lisp index 83fd3d7..a317232 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -300,7 +300,8 @@ ;; meaningful backtrace to the user in case of unexpected ;; conditions being signaled. (handler-bind - (((and condition (not (or cli-parsing-error + (((and condition (not (or monitor-error + cli-parsing-error source-definition-error regression-test-error))) #'(lambda (condition) @@ -362,6 +363,10 @@ (format *error-output* "~%~a~%~%" c) (uiop:quit +os-code-error-regress+)) + (monitor-error (c) + (format *error-output* "~a~%" c) + (uiop:quit +os-code-error+)) + (condition (c) (format *error-output* "~%What I am doing here?~%~%") (format *error-output* "~a~%~%" c) diff --git a/src/package.lisp b/src/package.lisp index 387ec4f..726ec3f 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -250,6 +250,7 @@ #:send-event #:start-monitor #:stop-monitor + #:monitor-error #:elapsed-time-since #:timing)) diff --git a/src/utils/monitor.lisp b/src/utils/monitor.lisp index 31248e0..91af9f0 100644 --- a/src/utils/monitor.lisp +++ b/src/utils/monitor.lisp @@ -36,6 +36,12 @@ (defstruct update-stats section label read rows errs secs rs ws bytes start stop) (defstruct bad-row section label condition data) +(define-condition monitor-error (error) + ((root-cause :initarg :root-cause :reader monitor-real-error)) + (:report (lambda (err stream) + (format stream "FATAL: Failed to start the monitor thread.~%") + (format stream "~%~a~%" (monitor-real-error err))))) + (defun log-message (category description &rest arguments) "Send given message into our monitoring queue for processing." (when (cl-log::category-messengers category) @@ -142,13 +148,20 @@ *monitoring-channel* (lp:make-channel) *monitoring-queue* (lq:make-queue)) - ;; warm up the channel to ensure we don't loose any event - (lp:submit-task *monitoring-channel* '+ 1 2 3) - (lp:receive-result *monitoring-channel*) + (lp:task-handler-bind + ((error + #'(lambda (c) + ;; we can't log-message a monitor thread error + (lp:invoke-transfer-error + (make-instance 'monitor-error :root-cause c))))) - ;; now that we know the channel is ready, start our long-running monitor - (lp:submit-task *monitoring-channel* #'monitor *monitoring-queue*) - (send-event (make-start :start-logger start-logger)) + ;; warm up the channel to ensure we don't loose any event + (lp:submit-task *monitoring-channel* '+ 1 2 3) + (lp:receive-result *monitoring-channel*) + + ;; now that we know the channel is ready, start our long-running monitor + (lp:submit-task *monitoring-channel* #'monitor *monitoring-queue*) + (send-event (make-start :start-logger start-logger))) (values *monitoring-kernel* *monitoring-queue* *monitoring-channel*)))