Handle eof when reading logs

This commit is contained in:
Christopher Baines 2023-11-05 18:49:11 +00:00
parent b026b8795b
commit 341eb4a283

View file

@ -72,33 +72,36 @@ VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, $2)")
(list job-id)) (list job-id))
(let loop ((line (get-line port-to-read-from))) (let loop ((line (get-line port-to-read-from)))
(let ((line-with-newline (if (eof-object? line)
(string-append line "\n"))) (simple-format #t "finished reading logs for ~A\n"
(catch #t job-id)
(lambda () (let ((line-with-newline
(insert logging-conn job-id line-with-newline) (string-append line "\n")))
(display line-with-newline))
(lambda (key . args)
(display
(simple-format
#f
"
error: ~A: ~A
error: could not insert log part: '~A'\n\n"
key args line))
(catch #t (catch #t
(lambda () (lambda ()
(insert (insert logging-conn job-id line-with-newline)
logging-conn (display line-with-newline))
job-id (lambda (key . args)
(display
(simple-format (simple-format
#f #f
" "
error: ~A: ~A
error: could not insert log part: '~A'\n\n"
key args line))
(catch #t
(lambda ()
(insert
logging-conn
job-id
(simple-format
#f
"
guix-data-service: error: missing log line: ~A guix-data-service: error: missing log line: ~A
\n" key))) \n" key)))
(lambda _ (lambda _
#t))))) #t))))
(loop (get-line port-to-read-from))))))) (loop (get-line port-to-read-from)))))))))
port-to-write-to))) port-to-write-to)))