How to catch the exception when cluster initialized failed with classic remotting

Looks like we have a temporarily issue with our network, and our Akka app restarted but failed to initialize the cluster/classic remotting codes, and it remains as a stale process, we have to manually restart the process.

According to the exception stack and the codes, I think the app timeouts when trying to bind the host and port, this is fine and the log is clear. But how could I catch this exception and shutdown the Akka app in a coordinate way?

BTW, we don’t have any resource allocated before the Akka actor system is fully functional.

2021-01-31 13:45:04,223 [ERROR] from akka.remote.Remoting in test-production-akka.actor.default-dispatcher-5 - Remoting error: [Startup timed out. This is usually related to actor system host setting or host name resolution misconfiguration.] [akka.remote.RemoteTransportException: Startup timed out. This is usually related to actor system host setting or host name resolution misconfiguration.
  at akka.remote.Remoting.akka$remote$Remoting$$notifyError(Remoting.scala:163)
  at akka.remote.Remoting.start(Remoting.scala:235)
  at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:259)
  at akka.cluster.ClusterActorRefProvider.init(ClusterActorRefProvider.scala:48)
  at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:1027)
  at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:1023)
  at akka.actor.ActorSystemImpl._start(ActorSystem.scala:1023)
  at akka.actor.ActorSystemImpl.start(ActorSystem.scala:1046)
  at akka.actor.ActorSystem$.apply(ActorSystem.scala:283)
  at akka.actor.ActorSystem$.apply(ActorSystem.scala:327)
  at akka.actor.ActorSystem$.apply(ActorSystem.scala:271)
  at mypackage.test.Application$.delayedEndpoint$mypackage$test$Application$1(Application.scala:19)
  at mypackage.test.Application$delayedInit$body.apply(Application.scala:18)
  at scala.Function0.apply$mcV$sp(Function0.scala:39)
  at scala.Function0.apply$mcV$sp$(Function0.scala:39)
  at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
  at scala.App.$anonfun$main$1$adapted(App.scala:80)
  at scala.collection.immutable.List.foreach(List.scala:392)
  at scala.App.main(App.scala:80)
  at scala.App.main$(App.scala:78)
  at mypackage.test.Application$.main(Application.scala:18)
  at mypackage.test.Application.main(Application.scala)
Caused by: java.util.concurrent.TimeoutException: Futures timed out after [10000 milliseconds]
  at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:259)
  at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:263)
  at scala.concurrent.Await$.$anonfun$result$1(package.scala:220)
  at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:57)
  at scala.concurrent.Await$.result(package.scala:146)
  at akka.remote.Remoting.start(Remoting.scala:214)
  ... 22 more
]