Skip to content

Commit

Permalink
Merge pull request #1848 from ergoplatform/SIGTERM-signal-shouldbe-ha…
Browse files Browse the repository at this point in the history
…ndled-as-remote-shutdown

SIGTERM should be handled as remote shutdown
  • Loading branch information
kushti authored Oct 1, 2022
2 parents 45e4788 + 591b4dd commit ff1f075
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 ff1f075

Please sign in to comment.