Tuesday, July 4, 2017

What does play fork run do?

Leave a Comment

I'm using play framework and having issues with hotswapping (or even timely starting up the sbt server)

Several sources have outlines this issue to be something to do with play's fork run, and that to solve it one should turn it to false.

But what is play fork run doing and what are the downsides to turning it off?

BTW here are some references:

solution outlining fork run as culprit

another solution, same thing

1 Answers

Answers 1

Play fork run, is a function of sbt where the JVM is forked. Forking a JVM means that the JVM is run as a separate JVM running as a different process in the OS.

If a JVM is not forked it may be that certain JVM wide settings for example system properties affect the play instance. One of the pros is that when the fork crashes for example when you are running multiple tests in multiple forks the other forks will still continue running.

In the case of play the JVM is forked such that it is not run in the same JVM process as sbt is running. See the following (from sbt documentation):

By default, the run task runs in the same JVM as sbt. Forking is required under certain circumstances, however. Or, you might want to fork Java processes when implementing new tasks.

This is usefull because if your play instance crashes for example, when system.exit is called or unterminated threads occur, sbt will keep running. Otherwise sbt would have crashed too.

references:
What does it mean to have a forked java VM?
Getting Started with SBT for Scala

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment