sbt没有在分叉设置中设置javaOptions

时间:2016-01-25 17:07:42

标签: scala playframework-2.0 sbt aspectj akka-monitoring

我试图使用Kamon检测我的服务器,这需要Aspectj weaver。我使用的是sbt 0.13.8

但是,选项不会传递给分叉进程。

我看过这里:

https://github.com/eigengo/activator-akka-aspectj/blob/master/build.sbt

在这里:

http://www.scala-sbt.org/0.13/docs/Forking.html

这是我的build.sbt:

import sbt.Keys._

name := """myApp"""

version := "0.0.1"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  //jdbc, don not enable this when using slick
  cache,
  ws,
  specs2 % Test,
  "com.typesafe.akka" %% "akka-contrib" % "2.4.+",
  "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
  "org.scalatestplus" %% "play" % "1.4.0-M3" % "test",
  "com.github.seratch" %% "awscala" % "0.5.+",
  "com.typesafe.play" %% "play-slick" % "1.1.1",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
  "mysql" % "mysql-connector-java" % "5.1.+",
  "commons-net" % "commons-net" % "3.3",
  "net.sourceforge.htmlcleaner" % "htmlcleaner" % "2.15",
  "io.strongtyped" %% "active-slick" % "0.3.3",
  "org.aspectj" % "aspectjweaver" % "1.8.8",
  "org.aspectj" % "aspectjrt" % "1.8.8",
  "io.kamon" %% "kamon-core" % "0.5.+",
//  "io.kamon" %% "kkamon-system-metrics" % "0.5.+",
  "io.kamon" %% "kamon-scala" % "0.5.+",
//  "io.kamon" %% "kamon-akka" % "0.5.+",
  "io.kamon" %% "kamon-datadog" % "0.5.+"
)

resolvers ++= Seq(
  "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

javaOptions in run += "-javaagent:" + System.getProperty("user.home") + "/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.8.jar -Xmx:2G"
fork in run := true
connectInput in run := true

我已尝试使用./activator start以及./activator stage运行该应用,然后运行该脚本。

我做错了什么?

谢谢!

1 个答案:

答案 0 :(得分:0)

生产应用程序应在部署期间配置。这是我的启动脚本示例:

PARAMETERS="-Dconfig.file=conf/production.conf -Dlogger.file=conf/prod-logger.xml"
PARAMETERS="$PARAMETERS -Dhttp.port=9000"
PARAMETERS="$PARAMETERS -J-Xmx8g -J-Xms8g -J-server -J-verbose:gc -J-Xloggc:../logs/portal/gc.log -J-XX:+PrintGCDateStamps"

nohup bin/myApp $PARAMETERS  &

有关详细信息,请参阅Production Configuration