Skip to content

Instantly share code, notes, and snippets.

@tlockney
Created December 14, 2012 21:46
Show Gist options
  • Save tlockney/4288931 to your computer and use it in GitHub Desktop.
Save tlockney/4288931 to your computer and use it in GitHub Desktop.
val javaRuntimeOptions = Seq(
"-Xmx2048M",
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSClassUnloadingEnabled",
"-XX:MaxPermSize=512M",
"-Xshare:off",
"-Dcom.sun.management.jmxremote.port=9998",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Djava.rmi.server.hostname=%s".format(hostname),
"-Djava.rmi.server.useLocalHostname=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=./"
)
settings += (resourceGenerators in Compile) <+= (resourceManaged, version) map { (dir, version) =>
val runScript = dir / "scriptName"
IO.write(runScript, genRunScript(version))
Seq(runScript)
}
def genRunScript(version: String) = {
val runtimeOptions = javaRuntimeOptions.mkString(" \\\n")
"""#!/bin/sh
|
|java -classpath ./appname-%s.jar:. \
|%s \
|foo.bar.MainClass""".stripMargin.format(version, runtimeOptions)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment