Skip to content

Commit

Permalink
Add shutdown listener and block queue before exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Oct 1, 2024
1 parent 80ccc17 commit 3a69297
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/cloudgene/mapred/server/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import java.util.List;
import java.util.Map;

import cloudgene.mapred.jobs.AbstractJob;
import cloudgene.mapred.jobs.engine.handler.IJobErrorHandler;
import cloudgene.mapred.jobs.engine.handler.JobErrorHandlerFactory;
import cloudgene.mapred.util.Configuration;
import io.micronaut.runtime.event.ApplicationShutdownEvent;
import io.micronaut.runtime.event.annotation.EventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -118,6 +121,14 @@ public Application() throws Exception {

}

@EventListener
public void stop(final ApplicationShutdownEvent event) throws SQLException {
System.out.println("Shutting down Cloudgene...");
log.info("Shutting down Cloudgene...");
engine.block();
database.disconnect();
}

public WorkflowEngine getWorkflowEngine() {
return engine;
}
Expand Down

0 comments on commit 3a69297

Please sign in to comment.