Skip to content

Commit 6004f11

Browse files
pditommasocgoina
authored andcommitted
Fix LogsCheckpoint thread blocking shutdown for up to 90 seconds (#6787)
1 parent fe46f93 commit 6004f11

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

plugins/nf-tower/src/main/io/seqera/tower/plugin/LogsCheckpoint.groovy

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class LogsCheckpoint implements TraceObserverV2 {
4040
private Thread thread
4141
private Duration interval
4242
private LogsHandler handler
43-
private volatile boolean terminated
4443

4544
@Override
4645
void onFlowCreate(Session session) {
@@ -57,23 +56,21 @@ class LogsCheckpoint implements TraceObserverV2 {
5756

5857
@Override
5958
void onFlowComplete() {
60-
this.terminated = true
59+
thread.interrupt()
6160
thread.join()
6261
}
6362

6463
@Override
6564
void onFlowError(TaskEvent event) {
66-
this.terminated = true
65+
thread.interrupt()
6766
thread.join()
6867
}
6968

7069
protected void run() {
7170
log.debug "Starting logs checkpoint thread - interval: ${interval}"
7271
try {
73-
while( !terminated && !Thread.currentThread().isInterrupted() ) {
74-
// just wait the declared delay
72+
while( !Thread.currentThread().isInterrupted() ) {
7573
await(interval)
76-
// checkpoint the logs
7774
handler.saveFiles()
7875
}
7976
}
@@ -87,7 +84,7 @@ class LogsCheckpoint implements TraceObserverV2 {
8784
Thread.sleep(interval.toMillis())
8885
}
8986
catch (InterruptedException e) {
90-
log.trace "Interrupted logs checkpoint thread"
87+
log.debug "Interrupted logs checkpoint thread"
9188
Thread.currentThread().interrupt()
9289
}
9390
}

0 commit comments

Comments
 (0)