Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
run sub process while runnning play
name := "fuga"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)
play.Project.playScalaSettings
playRunHooks += { SubProcess("tail -f /var/log/system.log") }
import sbt._
import Process._
import Keys._
import play.PlayRunHook
object SubProcess {
def apply(command: String): PlayRunHook = {
object SubProcessHook extends PlayRunHook {
var process: Option[Process] = None
override def beforeStarted(): Unit = {
process = Some(Process(command).run)
}
override def afterStopped(): Unit = {
process.map(p => p.destroy())
process = None
}
}
SubProcessHook
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment