Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent Play from auto-reloading?

While working on some projects, I would sometimes prefer to disable by the auto-reloading feature of Play (and only reload manually).

Is there a way to quickly achieve this? (Other than typing start at the play prompt, which adds some overhead as it packages the app.)

like image 587
Alex Archambault Avatar asked Jun 09 '14 10:06

Alex Archambault


1 Answers

Create a new Scala app that will start the Play app:

import play.api.{Application, ApplicationLoader, Environment, Mode, Play}
import play.core.server.{ServerConfig, ServerProvider}

object MyPlayApp extends App {

  val config = ServerConfig(mode = Mode.Dev)

  val application: Application = {
    val environment = Environment(config.rootDir, this.getClass.getClassLoader, Mode.Dev)
    val context = ApplicationLoader.createContext(environment)
    val loader = ApplicationLoader(context)
    loader.load(context)
  }

  Play.start(application)

  val serverProvider: ServerProvider = ServerProvider.fromConfiguration(this.getClass.getClassLoader, config.configuration)
  serverProvider.createServer(config, application)

}

Then run it: sbt "runMain MyPlayApp"

like image 197
James Ward Avatar answered Nov 15 '22 04:11

James Ward