[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: Handle eof when reading logs
From: |
Christopher Baines |
Subject: |
04/07: Handle eof when reading logs |
Date: |
Thu, 9 Nov 2023 11:45:02 -0500 (EST) |
cbaines pushed a commit to branch master
in repository data-service.
commit 341eb4a2838ff1d39601f22badcb99a19acbab0c
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Nov 5 18:49:11 2023 +0000
Handle eof when reading logs
---
guix-data-service/jobs.scm | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/guix-data-service/jobs.scm b/guix-data-service/jobs.scm
index 9bac5e1..f848f2e 100644
--- a/guix-data-service/jobs.scm
+++ b/guix-data-service/jobs.scm
@@ -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)))
- branch master updated (2135bc5 -> 37a07c2), Christopher Baines, 2023/11/09
- 05/07: Handle derivations with no sources, Christopher Baines, 2023/11/09
- 02/07: Restore #:error-port when calling open-inferior, Christopher Baines, 2023/11/09
- 01/07: Remove #:use-module (ice-9 custom-ports), Christopher Baines, 2023/11/09
- 07/07: Try to avoid the metrics timing out, Christopher Baines, 2023/11/09
- 06/07: Add missing empty job log entry, Christopher Baines, 2023/11/09
- 04/07: Handle eof when reading logs,
Christopher Baines <=
- 03/07: Remove peek, Christopher Baines, 2023/11/09