Skip to content

Commit

Permalink
Exit Teku if any service fails to start
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 committed Jan 9, 2025
1 parent cc94afc commit 35497fb
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import tech.pegasys.teku.infrastructure.async.eventthread.AsyncRunnerEventThread;
import tech.pegasys.teku.infrastructure.collections.LimitedMap;
import tech.pegasys.teku.infrastructure.events.EventChannels;
import tech.pegasys.teku.infrastructure.exceptions.ExceptionUtil;
import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException;
import tech.pegasys.teku.infrastructure.io.PortAvailability;
import tech.pegasys.teku.infrastructure.metrics.SettableGauge;
Expand Down Expand Up @@ -384,21 +385,21 @@ protected void startServices() {
() -> terminalPowBlockMonitor.ifPresent(TerminalPowBlockMonitor::start)))
.finish(
error -> {
Throwable rootCause = Throwables.getRootCause(error);
final Throwable rootCause = Throwables.getRootCause(error);
final String errorDescription;
if (rootCause instanceof BindException) {
final String errorWhilePerformingDescription =
errorDescription =
"starting P2P services on port(s) "
+ p2pNetwork.getListenPorts().stream()
.map(Object::toString)
.collect(Collectors.joining(","))
+ ".";
STATUS_LOG.fatalError(errorWhilePerformingDescription, rootCause);
System.exit(FATAL_EXIT_CODE);

} else {
Thread.currentThread()
.getUncaughtExceptionHandler()
.uncaughtException(Thread.currentThread(), error);
errorDescription = ExceptionUtil.getMessageOrSimpleName(rootCause);
}
STATUS_LOG.fatalError(errorDescription, rootCause);
System.exit(FATAL_EXIT_CODE);
});
}

Expand Down

0 comments on commit 35497fb

Please sign in to comment.