Is it possible to start the Play Framework 2.0 server with javaagent?

I would like to be able to start the Play Framework 2.0 server using javaagent.

Some resources on the Internet (see here and here ) suggest that this can be done by simply adding -javaagent:/path/to/agent.jarin play run, but it doesn't seem to work for me.

Any clues?

+5
source share
4 answers

There is no clean way to pass the -javaagent parameter to invoke the java command with playback 2.0.1-2.0.4 without changing the script.

I was able to get javaagent using the following technique:

# Modify the play/framework/build script to include an extra environment variable
sed -i 's/^java\( \${PLAY_OPTS}\)\?/java ${PLAY_OPTS}/' ${playPath}/framework/build

You can then pass the -javaagent parameter this way:

export PLAY_OPTS='-javaagent:/lib/newrelic/newrelic.jar'

${playPath}/play -Dconfig.file=conf/prod.conf -Dlogger.file=conf/prod-logger.xml start


Update

sidenote - New-Relic, New-Relic play-framework 2.x (2012-10-04).


+2

Heroku, , ( Procfile):

  play ${JAVA_OPTS} ${MYCONFIG} -javaagent:/newrelic/newrelic.jar run

newrelic ,

+2

java SBT "build.bat" (Win) "build" shell script (U * X), ​​ %PLAY2_HOME%/framework

javagent JVM, SBT/Play2, , . , , Heroku.

+2

The reason the examples do not work is because the examples are for Play 1.x and you are using 2.x. Play 1.x uses Java (via python scripts), where when Play 2 uses SBT.

You need to configure SBT. I'm not an SBT expert, but from Googling I would have thought it just worked

play -javaagent:/path/to/agent.jar

and then, after runstarting the console, it should do the trick, but if that doesn't work, then this is the case when you learn how to add javaagent syntax to the SBT console.

+1
source

All Articles