Currently, Lagom’s built-in tooling allows for running a single service via run
or all of them via runAll
. In some cases you may find it more convenient to run a specific subset of services. The simplest solution for this is to create a commandAlias
for starting the appropriate services (including built-in ones):
addCommandAlias(
"runAandB",
";lagomServiceLocatorStart;lagomCassandraStart;all serviceA/run serviceB/run"
)
If you are running a mixed Play/Lagom project, then this could result in port collisions. This can be worked around by binding to another port.
If, however, you have one or more Lagom services which enabled both the PlayScala
and the LagomScala
plugins, then a command collision on run
may occur. This is because both define run
, so using serviceA/run
is ambiguous such that one implementation wins over the other. And the implementations differ quite a bit between the Play implementation and the Lagom one since in Lagom services must register and also expose call paths on the service gateway (plus handle port assignment as already mentioned). There’s no way to enforce one implementation over the other but you can provide your own:
lazy val `hello-world-impl` = (project in file("hello-world-impl"))
.enablePlugins(LagomScala, PlayScala)
.disablePlugins(PlayLayoutPlugin)
.settings(
Keys.run in Compile := {
val service = lagomRun.value
}
)
//... more settings
// more projects
addCommandAlias(
"runAandB",
";lagomServiceLocatorStart;lagomCassandraStart;lagomKafkaStart;all hello-world-impl/run hello-world-stream-impl/run "
)
The sbt code above overwrites run
ensuring the invocation of hello-world-impl/run
causes the lagomRun
implementation to execute.