Created
April 8, 2011 19:01
-
-
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'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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