Handle eof when reading logs
This commit is contained in:
parent
b026b8795b
commit
341eb4a283
|
@ -72,33 +72,36 @@ VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, $2)")
|
|||
(list job-id))
|
||||
|
||||
(let loop ((line (get-line port-to-read-from)))
|
||||
(let ((line-with-newline
|
||||
(string-append line "\n")))
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(insert logging-conn job-id line-with-newline)
|
||||
(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))
|
||||
(if (eof-object? line)
|
||||
(simple-format #t "finished reading logs for ~A\n"
|
||||
job-id)
|
||||
(let ((line-with-newline
|
||||
(string-append line "\n")))
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(insert
|
||||
logging-conn
|
||||
job-id
|
||||
(insert logging-conn job-id line-with-newline)
|
||||
(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
|
||||
(lambda ()
|
||||
(insert
|
||||
logging-conn
|
||||
job-id
|
||||
(simple-format
|
||||
#f
|
||||
"
|
||||
guix-data-service: error: missing log line: ~A
|
||||
\n" key)))
|
||||
(lambda _
|
||||
#t)))))
|
||||
(loop (get-line port-to-read-from)))))))
|
||||
(lambda _
|
||||
#t))))
|
||||
(loop (get-line port-to-read-from)))))))))
|
||||
|
||||
port-to-write-to)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue