def startNode()

in pekko-sample-persistence-dc-scala/src/main/scala/sample/persistence/res/MainApp.scala [50:75]


  def startNode(port: Int, dc: String): Unit = {
    implicit val system: ActorSystem[Nothing] =
      ActorSystem[Nothing](Behaviors.empty[Nothing], "ClusterSystem", config(port, dc))
    implicit val ec: ExecutionContext = system.executionContext

    val replicatedSharding = ReplicatedShardingExtension(system)
    val thumbsUpReplicatedSharding: ReplicatedSharding[ThumbsUpCounter.Command] =
      replicatedSharding.init(ThumbsUpCounter.Provider)

    // no HTTP end points for them, just showing that multiple replicated sharding instances can be started
    val bankAccountReplicatedSharding: ReplicatedSharding[BankAccount.Command] =
      replicatedSharding.init(BankAccount.Provider)

    if (port != 0) {
      val httpHost = "0.0.0.0"
      val httpPort = 20000 + port
      Http().newServerAt(httpHost, httpPort)
        .bind(ThumbsUpHttp.route(ReplicaId(dc), thumbsUpReplicatedSharding))
        .onComplete {
          case Success(_)  => system.log.info("HTTP Server bound to http://{}:{}", httpHost, httpPort)
          case Failure(ex) => system.log.error(s"Failed to bind HTTP Server to http://$httpHost:$httpPort", ex)
        }
      PekkoManagement(system).start()
    }

  }