Reputation: 165
I've been asked to look into some performance issues with a Playframework 2.2.3 application. I have previous experience with playframework 1 but I realise 2.x is very different.
Has anyone managed to use Yourkit profiler with play 2? I managed to attach the agent by adding an option to the java command in framework/build script. This only attaches the agent to the sbt launcher and therefore the agent dies once the real application is launched.
Does anyone have a solution for this? Perhaps I need to use 'play dist'
Jon
Upvotes: 2
Views: 1411
Reputation: 1196
With Play 2.4, you can enable YourKit for production distributions on Unix/Linux systems (not running within SBT) with the SBT plugin sbt-yourkit. This will add the appropriate YourKit agent shared object, and startup flags, to allow the agent to be used by Play in production.
The agent is added to the archive generated by sbt dist
, or other build targets described here.
The steps to add the plugin are:
Add the plugin to your SBT build, e.g. add the following to project/plugins.sbt
:
addSbtPlugin("com.gilt.sbt" % "sbt-yourkit" % "0.0.2")
Add the YourKit
AutoPlugin to your project definition, e.g. add the following to build.sbt
:
enablePlugins(YourKit)
Further information is available at the plugin link above.
Note: This does not enable YourKit debugging in Play's development mode. If you want to test your program with YourKit locally, possibly the easiest way of doing this is to use the universal:stage
target to create a directory containing your application - this will usually create a directory under <PROJECT_DIRECTORY>/target/universal/stage
, and you can run your application (including YourKit integration) from the script in the bin/
directory.
Upvotes: 0
Reputation: 61
To anyone else coming here to find out just how to get Yourkit working togeather with Play 2x in IntelliJ - here is a quick summary of what I did based on the accepted answer:
1) Installed Yourkit and verified the plugin was showing in IntelliJ.
2) Edited my run config in IntelliJ after installing yourkit, adding the following to JVM options: -agentpath:C:\PROGRA~2\YOURKI~1\bin\win64\yjpagent.dll
Insert the path to your yourkit (x86 has win32 instead). I had troubles with using windows style path, and had to use DOS short version for this to work. Here you find the manual on Enabling profiling manually!
Upvotes: 0
Reputation: 11479
One way would be to create a dist and run it from there with the parameters, you will get a runnable under target/universal/stage/bin/yourappname
that you can pass parameters to with JAVA_OPTS
or the -J-...
parameter.
The other way is to provide the same parameter but through your sbt config, which will then be passed to the same script (start just builds and runs), note that since it is the script and not the actual jvm you need the -J
prefix to any parameter you want to send to the JVM:
javaOptions in Production += "-J-something"
Upvotes: 2