Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created April 2, 2014 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakobe/9925774 to your computer and use it in GitHub Desktop.
Save hakobe/9925774 to your computer and use it in GitHub Desktop.
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