grails-gradle-plugin-archived icon indicating copy to clipboard operation
grails-gradle-plugin-archived copied to clipboard

Grails 2.3.1 Forked Execution

Open cerny opened this issue 11 years ago • 10 comments

Forked execution of Tomcat server does not worked as expected.

In Grails 2.3.1, forking is enabled by default, but it seems that the grails-launcher plugin, which is used by the grails-gradle-plugin, does not create another process for Tomcat. This causes a PermGen, sometimes immediately at startup and other times while using the launched app.

cerny avatar Nov 06 '13 20:11 cerny

Interesting. The issue I raised against Grails specifically requested that the forking be disabled when external build tools are used. I suspect that means the Grails Gradle plugin needs to be updated to fork the execution of its commands.

pledbrook avatar Nov 11 '13 11:11 pledbrook

I got around this by creating a custom GrailsTask in my build.gradle file.

The default MaxPermSize was around 80m, so I increased it using the following:

task grailsRunApp(type: GrailsTask) { command "run-app" jvmOptions { jvmArgs (['-XX:PermSize=128m', '-XX:MaxPermSize=512m']) } }

cerny avatar Nov 11 '13 15:11 cerny

Another option is to set the fork options for all GrailsTask instances:

tasks.withType(org.grails.gradle.plugin.tasks.GrailsTask) { Task t ->
    t.jvmOptions {
        jvmArgs "-Xmx384mx", "-XX:MaxPermSize=256m"
    }
}

It looks like Gradle uses the defaults of the JVM you're using if you don't set explicit options, although I'm not entirely sure on that point.

pledbrook avatar Nov 13 '13 15:11 pledbrook

@pledbrook that's correct, it's up to the JVM.

ldaley avatar Nov 14 '13 09:11 ldaley

I think the plugin should set some reasonable defaults for the forked VM, as long as those defaults can be overridden.

pledbrook avatar Nov 15 '13 08:11 pledbrook

Not sure how to determine what these reasonable defaults would be.

ldaley avatar Nov 15 '13 18:11 ldaley

The grails_opts from the grailsw script would probably be a reasonable default

On Fri, Nov 15, 2013 at 10:01 AM, Luke Daley [email protected]:

Not sure how to determine what these reasonable defaults would be.

— Reply to this email directly or view it on GitHubhttps://github.com/grails/grails-gradle-plugin/issues/48#issuecomment-28589769 .

cfieber avatar Nov 15 '13 18:11 cfieber

@pledbrook Are you going to add these defaults?

ldaley avatar Dec 07 '13 23:12 ldaley

Not right now. I do need to go over the Gradle integration for Grails in Action again, so I might be able to take a look at it then. Not sure whether to do a tasks.withType() configuration block or set the JVM options from the GrailsTask constructor.

pledbrook avatar Dec 08 '13 21:12 pledbrook

For completeness, this is what is in grailsw:

if [ -n "$GRAILS_OPTS" ]
    then
  GRAILS_OPTS="$GRAILS_OPTS"
    else
  GRAILS_OPTS="-server -Xmx768M -Xms64M -XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=U
fi

johnrengelman avatar Feb 06 '14 00:02 johnrengelman