Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server stops immediately when runPlay is run from another tasks #158

Open
cataphract opened this issue Nov 16, 2020 · 4 comments
Open

Server stops immediately when runPlay is run from another tasks #158

cataphract opened this issue Nov 16, 2020 · 4 comments

Comments

@cataphract
Copy link

cataphract commented Nov 16, 2020

Gradle 6.6.1. Version 0.10

Not sure what's going on here. The application runs fine from the distribution tar and if runPlay is called directly. I can see that the server starts and that port 8080 is bound but then PlayWorkerServer::stop() is called.

// TOP project
def jvmArgs = /* ... */
def createSampleAppTarget = { name, target ->
    tasks.create(name: name, type: GradleBuild, dependsOn: shadowJar) {
        description = "Run $target with instrumentation"
        group = 'application'

        startParameter = startParameter.newInstance()
        startParameter.projectProperties = [
                jvmArgs       : "-javaagent:$shadowJar.archivePath $jvmArgs",
                debugJvm      : project.hasProperty('debugJvm') ? project.debugJvm : 'false',
        ]
        tasks = [target]
    }
}

createSampleAppTarget 'runInstrumentedPlayApp', ':samplePlayApp:runPlay'
// SUBPROJECT
runPlay {
    httpPort = 8080

    // TODO: possible to change executable? doesn't look like so
    def jvmArgs = []
    if (project.hasProperty('jvmArgs')) {
        jvmArgs += (project.jvmArgs.split(/\s+/) as List)
    }

    if (project.hasProperty('debugJvm') && project.debugJvm == 'true') {
        jvmArgs += ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:5005']
    }
    forkOptions.jvmArgs = jvmArgs
}

I can't reproduce this is the task that calls the runPlay task is in the same project.

@maiksaray
Copy link

I think I've reproduced this within the same project and can't yet grasp the issue here:

task debugPlay {
    def runPlayTask = tasks.findByName('runPlay')
    runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999']
    doLast {
        runPlayTask.run()
    }
}

seems to be simple approach to debugging, but play stops immediately.

@maiksaray
Copy link

And it was pretty easy to get what's happening from here.
The issue is that runPlay task specifies file input tracking to trigger continuous build in gradle and it stays running.
Custom tasks that just run runPlay do not and they just end.
I specified inputs.files(runPlayTask.getAssetsDirs()) in my debugPlay configuration (actually I don't think it matters what to track here) and got task hanging there in continuous build.
Hope this helps @cataphract

Not sure this can be / should be fixed in plugin (however debug task would be nice)

@devYonz
Copy link

devYonz commented Dec 19, 2020

I think I've reproduced this within the same project and can't yet grasp the issue here:

task debugPlay {
    def runPlayTask = tasks.findByName('runPlay')
    runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999']
    doLast {
        runPlayTask.run()
    }
}

seems to be simple approach to debugging, but play stops immediately.

Does this mean you all are able to set debug breakpoints using this setup? I'm trying to get the same going over command line with : GRADLE_OPTS="-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" gradle --no-daemon run but never hitting the breakpoint in intellij

[UPDATE]
In the end this setup worked for me:
$ gradle runPlay -Ddebug=true

play {
    injectedRoutesGenerator = true
    platform {
        playVersion = playV
        scalaVersion = scalaV
        javaVersion = javaV
        if (System.getProperty("debug")) {
            def runPlayTask = tasks.findByName('runPlay')
            runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005']
        }
    }
}

if you don't want the daemon to wait for connection just flipt the jwdt suspend to n:
runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005']

@Jonatha1983
Copy link

@yfeleke long time passed but maybe you remember if you did this and used the remote debug in intellij or simply local debug ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants