Skip to content

Instantly share code, notes, and snippets.

@acreeger
Created April 8, 2011 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acreeger/910504 to your computer and use it in GitHub Desktop.
Save acreeger/910504 to your computer and use it in GitHub Desktop.
A script that allows you launch a grails-app then launch a JConsole instance that connects to it. Useful for using JMX with a grails app. Place this in your 'scripts' folder. Usage: 'grails jconsole'
import java.lang.management.ManagementFactory
includeTargets << grailsScript("_GrailsPackage")
includeTargets << grailsScript("_GrailsRun")
target(main: "Launches an app and automatically launches JConsole") {
//depends(compile, classpath, runApp)
depends(checkVersion, configureProxy, packageApp, parseArguments)
if (argsMap.https) {
runAppHttps()
}
else {
runApp()
}
def name = ManagementFactory.getRuntimeMXBean().getName()
def pid = name[0..name.indexOf('@')-1]
ant.echo("Launching jconsole, connecting to process with id: $pid")
['jconsole',pid].execute()
watchContext()
}
setDefaultTarget(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment