in pekko-sample-sharding-scala/killrweather/src/main/scala/sample/killrweather/KillrWeather.scala [15:38]
def main(args: Array[String]): Unit = {
val seedNodePorts = ConfigFactory.load().getStringList("pekko.cluster.seed-nodes")
.asScala
.flatMap { case AddressFromURIString(s) => s.port }
// Either use a single port provided by the user
// Or start each listed seed nodes port plus one node on a random port in this single JVM if the user
// didn't provide args for the app
// In a production application you wouldn't start multiple ActorSystem instances in the
// same JVM, here we do it to simplify running a sample cluster from a single main method.
val ports = args.headOption match {
case Some(port) => Seq(port.toInt)
case None => seedNodePorts ++ Seq(0)
}
ports.foreach { port =>
val httpPort =
if (port > 0) 10000 + port // offset from pekko port
else 0 // let OS decide
val config = configWithPort(port)
ActorSystem[Nothing](Guardian(httpPort), "KillrWeather", config)
}
}