fix: harden document pipeline concurrency and diagnostics
- docreader: serialize all pdfium access behind a global lock. pypdfium2 is process-global and not thread-safe, so concurrent PDF uploads could corrupt its shared state and deadlock the whole process (requests stuck in "Parsing document" forever). Non-PDF parsers still run concurrently. - logger: strip ANSI color escapes from file logs so on-disk logs stay plain text while stdout keeps terminal colors. - storage: log baseDir/resolvedPath on file-open failure and when the multimodal service resolves a file service, so a LOCAL_STORAGE_BASE_DIR mismatch between writer and reader is immediately visible. - docker: set TZ (default Asia/Shanghai) for the docreader container.
This commit is contained in:
@@ -19,6 +19,22 @@ func newEntry(level logrus.Level, msg string, data logrus.Fields) *logrus.Entry
|
||||
return e
|
||||
}
|
||||
|
||||
func TestAnsiStripWriter(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
w := &ansiStripWriter{w: &buf}
|
||||
in := []byte("\x1b[32mINFO\x1b[0m hello \x1b[31mERROR\x1b[0m")
|
||||
n, err := w.Write(in)
|
||||
if err != nil {
|
||||
t.Fatalf("Write error: %v", err)
|
||||
}
|
||||
if n != len(in) {
|
||||
t.Fatalf("Write n = %d, want %d", n, len(in))
|
||||
}
|
||||
if got := buf.String(); got != "INFO hello ERROR" {
|
||||
t.Fatalf("stripped output = %q, want %q", got, "INFO hello ERROR")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormat_DefaultModeUnchanged(t *testing.T) {
|
||||
f := &CustomFormatter{} // no template, no color
|
||||
entry := newEntry(logrus.InfoLevel, "hello", logrus.Fields{
|
||||
|
||||
Reference in New Issue
Block a user