Oleg
Oleg

Reputation: 3200

Split play project into parts

I am having some play framework web project that consist of 3 logical parts: an userweb , an admin area and akka actors.

It's slowly growing up and I need to restart the production server for each small change. That's why I decided to split the project into 3 parts. The admin area communicates with the DB and the actors, so does the UI , actors communicate with the web part and the DB. And each part can be more or less painlessly restarted without restarting the other. But I don't want to split projects and only produce different JARS from one code base. Is it possible?

And another question is how to start akka actors standalone in Play framework environment?

Upvotes: 1

Views: 212

Answers (1)

yǝsʞǝla
yǝsʞǝla

Reputation: 16412

If you want to have 3 JARs that you run each separately on a different JVM and still have a single SBT project you can do it this way... The project structure in SBT:

root
  - admin
  - UI
  - DB

You can build each subproject separately or all at once when you build root.

To produce separate JARs you can use sbt-assembly plugin or onejar, or any other jar packager. Each JAR will contain a "Main" class (with main method) except for Play subproject if you run it on regular Servlet containers. If you run play on embedded Jetty it can have main as well.

Now for some links:

  • SBT multi-project setup
  • Akka remoting
  • SBT Assembly (JAR packager)
  • Sample remoting Akka project that matches your case: client - server where client is one subproject and server is another. It might not be the best reference but you can copy lot's of structure from there.

To start I would migrate your build from build.sbt to 'Build.scala`. Move Play project as SBT subproject and make it build. When this works start splitting it.

Upvotes: 4

Related Questions