mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Introduced bundle project and created main class that runs server and then gui (#1531)
Co-authored-by: nkohen <nadavk25@gmail.com>
This commit is contained in:
parent
f6e7764aad
commit
b52ec8b041
5 changed files with 51 additions and 1 deletions
10
app/bundle/bundle.sbt
Normal file
10
app/bundle/bundle.sbt
Normal file
|
@ -0,0 +1,10 @@
|
|||
name := "bitcoin-s-bundle"
|
||||
|
||||
mainClass := Some("org.bitcoins.bundle.AppBundle")
|
||||
|
||||
enablePlugins(JavaAppPackaging)
|
||||
|
||||
publish / skip := true
|
||||
|
||||
// Fork a new JVM for 'run' and 'test:run' to avoid JavaFX double initialization problems
|
||||
fork := true
|
|
@ -0,0 +1,12 @@
|
|||
package org.bitcoins.bundle
|
||||
|
||||
import org.bitcoins.gui.WalletGUI
|
||||
import org.bitcoins.server.{BitcoinSServer, Main}
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object AppBundle extends App {
|
||||
import ExecutionContext.Implicits.global
|
||||
BitcoinSServer.startedF.map(_ => WalletGUI.main(args))
|
||||
Main.main(args)
|
||||
}
|
|
@ -121,4 +121,8 @@ object WalletGUI extends JFXApp {
|
|||
model.taskRunner = taskRunner
|
||||
|
||||
Platform.runLater(sendButton.requestFocus())
|
||||
|
||||
override def stopApp(): Unit = {
|
||||
sys.exit(0) // Kills the server if GUI is closed in AppBundle
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.nio.file.{Files, Paths}
|
|||
import akka.actor.ActorSystem
|
||||
import org.bitcoins.chain.api.ChainApi
|
||||
import org.bitcoins.chain.blockchain.ChainHandler
|
||||
import akka.http.scaladsl.Http
|
||||
import org.bitcoins.chain.config.ChainAppConfig
|
||||
import org.bitcoins.chain.models.{BlockHeaderDAO, CompactFilterDAO, CompactFilterHeaderDAO}
|
||||
import org.bitcoins.core.Core
|
||||
|
@ -25,7 +26,7 @@ import org.bitcoins.wallet.config.WalletAppConfig
|
|||
import org.bitcoins.wallet.models.AccountDAO
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.concurrent.{Await, ExecutionContext, Future}
|
||||
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
|
||||
|
||||
object Main extends App {
|
||||
implicit val system = ActorSystem("bitcoin-s")
|
||||
|
@ -131,6 +132,8 @@ object Main extends App {
|
|||
start
|
||||
}
|
||||
|
||||
BitcoinSServer.startedFP.success(startFut)
|
||||
|
||||
startFut.failed.foreach { err =>
|
||||
logger.error(s"Error on server startup!", err)
|
||||
}
|
||||
|
@ -306,3 +309,18 @@ object Main extends App {
|
|||
} yield chainApiWithWork
|
||||
}
|
||||
}
|
||||
|
||||
object BitcoinSServer {
|
||||
private[server] val startedFP = Promise[Future[Http.ServerBinding]]()
|
||||
|
||||
/** Allows the above server to be bundled with other projects.
|
||||
*
|
||||
* Main.startFut will be null when called from elsewhere due
|
||||
* to the delayed initialization of scala Apps.
|
||||
*
|
||||
* In contrast this Future will be initialized immediately and
|
||||
* only initialized to to Main's startFut when that future has
|
||||
* been initialized.
|
||||
*/
|
||||
val startedF: Future[Http.ServerBinding] = startedFP.future.flatten
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ lazy val `bitcoin-s` = project
|
|||
bench,
|
||||
eclairRpc,
|
||||
eclairRpcTest,
|
||||
bundle,
|
||||
gui,
|
||||
keyManager,
|
||||
keyManagerTest,
|
||||
|
@ -265,6 +266,11 @@ lazy val cliTest = project
|
|||
testkit
|
||||
)
|
||||
|
||||
lazy val bundle = project
|
||||
.in(file("app/bundle"))
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.dependsOn(appServer, gui)
|
||||
|
||||
lazy val gui = project
|
||||
.in(file("app/gui"))
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
|
|
Loading…
Add table
Reference in a new issue