Skip to content

Commit

Permalink
SIGTERM should be handled as remote shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaxim committed Sep 28, 2022
1 parent 601cd17 commit 4e8e98e
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/main/scala/scorex/core/app/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scorex.core.app
import akka.actor.{ActorRef, ActorSystem}
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.{ExceptionHandler, RejectionHandler, Route}
import org.ergoplatform.ErgoApp
import org.ergoplatform.settings.ErgoSettings
import scorex.core.api.http.{ApiErrorHandler, ApiRejectionHandler, ApiRoute, CompositeHttpService}
import scorex.core.network._
Expand All @@ -17,9 +18,6 @@ import scala.concurrent.ExecutionContext

trait Application extends ScorexLogging {

import scorex.core.network.NetworkController.ReceivableMessages.ShutdownNetwork


//settings
val ergoSettings: ErgoSettings
implicit val scorexSettings: ScorexSettings
Expand Down Expand Up @@ -100,20 +98,8 @@ trait Application extends ScorexLogging {
Runtime.getRuntime.addShutdownHook(new Thread() {
override def run() {
log.error("Unexpected shutdown")
stopAll()
ErgoApp.shutdownSystem()
}
})
}

def stopAll(): Unit = synchronized {
log.info("Stopping network services")
upnpGateway.foreach(_.deletePort(scorexSettings.network.bindAddress.getPort))
networkControllerRef ! ShutdownNetwork

log.info("Stopping actors (incl. block generator)")
actorSystem.terminate().onComplete { _ =>
log.info("Exiting from the app...")
System.exit(0)
}
}
}

0 comments on commit 4e8e98e

Please sign in to comment.