mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Merge pull request #1268 from benthecarman/cli-stop
CLI command to stop node
This commit is contained in:
commit
47c2bc08c4
@ -148,6 +148,9 @@ object ConsoleCli {
|
||||
cmd("getpeers")
|
||||
.action((_, conf) => conf.copy(command = GetPeers))
|
||||
.text(s"List the connected peers"),
|
||||
cmd("stop")
|
||||
.action((_, conf) => conf.copy(command = Stop))
|
||||
.text("Request a graceful shutdown of Bitcoin-S"),
|
||||
note(sys.props("line.separator") + "=== PSBT ==="),
|
||||
cmd("combinepsbts")
|
||||
.action((_, conf) => conf.copy(command = CombinePSBTs(Seq.empty)))
|
||||
@ -275,6 +278,7 @@ object ConsoleCli {
|
||||
case GetBestBlockHash => RequestParam("getbestblockhash")
|
||||
// peers
|
||||
case GetPeers => RequestParam("getpeers")
|
||||
case Stop => RequestParam("stop")
|
||||
// PSBTs
|
||||
case CombinePSBTs(psbts) =>
|
||||
RequestParam("combinepsbts", Seq(up.writeJs(psbts)))
|
||||
@ -386,6 +390,7 @@ object CliCommand {
|
||||
|
||||
// Node
|
||||
case object GetPeers extends CliCommand
|
||||
case object Stop extends CliCommand
|
||||
|
||||
// Chain
|
||||
case object GetBestBlockHash extends CliCommand
|
||||
|
@ -8,12 +8,22 @@ import org.bitcoins.node.Node
|
||||
|
||||
case class NodeRoutes(node: Node)(implicit system: ActorSystem)
|
||||
extends ServerRoute {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
import system.dispatcher
|
||||
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||
|
||||
def handleCommand: PartialFunction[ServerCommand, StandardRoute] = {
|
||||
case ServerCommand("getpeers", _) =>
|
||||
complete {
|
||||
Server.httpSuccess("TODO implement getpeers")
|
||||
}
|
||||
|
||||
case ServerCommand("stop", _) =>
|
||||
complete {
|
||||
val nodeStopping = node.stop().map { _ =>
|
||||
Server.httpSuccess("Node shutting down")
|
||||
}
|
||||
system.terminate()
|
||||
nodeStopping
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user