Skip to content

Commit

Permalink
fix: Application does not terminate if severe error occurs #185 (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: Aliaksandr Stsiapanay <[email protected]>
  • Loading branch information
astsiapanay and astsiapanay authored Feb 14, 2024
1 parent 26105d5 commit 2e1da2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/epam/aidial/core/AiDial.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void start() throws Exception {

log.info("Proxy started on {}", server.actualPort());
} catch (Throwable e) {
log.warn("Proxy failed to start:", e);
log.error("Proxy failed to start:", e);
stop();
throw e;
}
Expand Down Expand Up @@ -240,7 +240,11 @@ private interface AsyncCloser<R> {

public static void main(String[] args) throws Exception {
AiDial dial = new AiDial();
dial.start();
try {
dial.start();
} catch (Throwable e) {
System.exit(-1);
}
Runtime.getRuntime().addShutdownHook(new Thread(dial::stop, "shutdown-hook"));
}

Expand Down

0 comments on commit 2e1da2b

Please sign in to comment.