5

I have a Scala Play Framework web-application (using Scala v2.13.7 and Play v2.8.8) built using SBT (v1.5.5).

My build.sbt includes the following:

lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.settings(

  // etc.

  fork := true,
  javaOptions ++= Seq(
    "-Xms1G",
    "-Xmx8G",
  ),
)

However, a separate JVM for the web-application is not spawned when I execute sbt run, and the memory settings are those of the SBT JVM (-Xms1024m and -Xmx1024m).

Does the PlayScala plugin interfere with or disable forking when running the web-application itself? Can I force the web-application to use a forked JVM from within SBT?

FunProg
  • 140
  • 11

2 Answers2

0

Based on the sbt documentation, Forked JVM Options, you may want to do something like:

lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.settings(

  // etc.

  javaOptions ++= Seq(
    "-Xms1G",
    "-Xmx8G",
  ),
  fork := true,
  run / javaOptions += "-Xms1G -Xmx8G",
)

I'm not very familiar with play, but this should resolve the issue you're facing.

Haris Nadeem
  • 1,322
  • 11
  • 24
  • It seems that you're recommending adding a `run / javaOptions` setting, correct? The problem is that a forked process is not created, despite the `fork := true` setting, so this change makes no difference. – FunProg Jan 03 '22 at 17:11
0

Sparing myself a long investigation on my part, if all you want to do is affect java options, set them (all in one or one per line is ok) in a file named .jvmopts in the sbt project root folder (-as mentioned elsewhere already).

conny
  • 9,973
  • 6
  • 38
  • 47
  • I realize I can do that, but the problem is that I'm unable to create a forked process, despite `forked := true` being present in the _SBT_ build. The _Java_ options were just to add flavor to the problem as presented here, but I do need the web-application to be forked when it runs. – FunProg Jan 03 '22 at 17:18