Created
April 2, 2014 00:23
-
-
Save hakobe/9925774 to your computer and use it in GitHub Desktop.
run sub process while runnning play
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "fuga" | |
version := "1.0-SNAPSHOT" | |
libraryDependencies ++= Seq( | |
jdbc, | |
anorm, | |
cache | |
) | |
play.Project.playScalaSettings | |
playRunHooks += { SubProcess("tail -f /var/log/system.log") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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