Skip to content

wait before error quit #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/main/java/com/uid2/operator/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.uid2.operator;

import ch.qos.logback.classic.LoggerContext;
import com.google.common.base.Strings;
import com.uid2.enclave.IOperatorKeyRetriever;
import com.uid2.operator.model.KeyManager;
Expand Down Expand Up @@ -194,12 +193,23 @@ else if (!Utils.isProductionEnvironment()) {
return;
}

boolean errorQuit = false;

try {
Main app = new Main(vertx, ar.result());
app.run();
} catch (Exception e) {
LOGGER.error("Error: " + e.getMessage(), e);
((LoggerContext)org.slf4j.LoggerFactory.getILoggerFactory()).stop(); // flush logs before shutdown
errorQuit = true;
}

if(errorQuit){
// allow log to be flushed before quit app.
try {
Thread.sleep(1000);
} catch (Exception e) {
// swallow
}
vertx.close();
System.exit(1);
}
Expand Down