Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGTERM should be handled as remote shutdown #1848

Merged
merged 2 commits into from
Oct 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
kushti marked this conversation as resolved.
Show resolved Hide resolved
networkControllerRef ! ShutdownNetwork

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