Blankman
Blankman

Reputation: 267000

Is it possible to run 2 sbt projects at the same time?

I have 2 sbt projects that are runnable (akka app and another play application).

Is it possible to run both of them, and use ~reStart so they refresh on any changes to my project?

Any tips on doing this correctly so I don't run out of memory also?

Upvotes: 2

Views: 674

Answers (2)

LineDrop
LineDrop

Reputation: 489

Open two different Terminal tabs; cd into the specific directory in each tab and then run with SBT.

sbt run

For multiple web apps, specify a different port:

sbt run -Dhttp.port=8888

Upvotes: 0

Bunyod
Bunyod

Reputation: 1371

If you are using Play Framework's latest version you can ~run without any plugin. Regarding standalone akka application you may use a library called sbt-revolver

runAkkaServer := {
  (reStart in Compile in `akka-server`).evaluated
}

runWebServer := {
  (~run in Compile in `web-server`).evaluated
}

mainClass in reStart := Some("com.example.MainAkka")

val runAkkaServer = inputKey[Unit]("Runs akka-server")
val runWebServer = inputKey[Unit]("Runs web-server")


NOTE: you can run both applications in restart mode without custom tasks: 1. ~run - Play server 2. reStart - Standalone

UPDATE:

I've tried to use following command to both of them, it seems that sbt-revolver is kinda trick and killing application onstart. When replace reStart with run it works perfect, but doesn't trigger changes.

 screen -d -m sbt runAppServer; screen -d -m sbt runWebServer

So above code just doesnot behave as expected. Instead of custom tasks, we can run them in separate windows like this:

screen -dmS "appserver" sh -c "sbt 'project appserver;~reStart'; exec bash" ;  screen -dmS "webserver" sh -c "sbt runWebServer; exec bash"

Also sbt runWebServer can be replaced by sbt 'project anothersubmodule;~run' if you wish.

I've created a simple demonstration project, you can find here In order to start you can call just: ./starter.sh

NOTE: you can install screen command if you don't have easily.

Upvotes: 1

Related Questions