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

Task startServer Hangs #20

Open
kirankbs opened this issue Aug 25, 2016 · 5 comments
Open

Task startServer Hangs #20

kirankbs opened this issue Aug 25, 2016 · 5 comments

Comments

@kirankbs
Copy link

Build is hanging at startServer.
It is not going ahead to execute remaining tasks.

build.gradle:-

apply plugin: 'com.wiredforcode.spawn'

task startServer(type: SpawnProcessTask, dependsOn: 'assemble') {
command "startApplication.bat"
ready 'Started.Application'
pidLockFileName ".new.pid.lock"
}

task stopServer(type: KillProcessTask)


cmd Output:-

gradle clean startS stopS
:clean
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war
:assemble
:startServer

gradlew jettyRunWar
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war
Building 75% > :startServer

@georgepapas
Copy link

+1 seeing the same issue, and no lock file is being created.

@brookslyrette
Copy link

Same here

@rafalima
Copy link

rafalima commented Jan 5, 2017

@georgepapas and @brookslyrette - I'm facing the same issue. Did you find any solution for it? thanks

@kaserf
Copy link

kaserf commented Jan 12, 2017

I had the same issue and I think I found out why it is happening. The "ready" directive means it is waiting for the string that you pass to it to appear on standard out. So you will have to specify something your "startApplication.bat" is printing on standard out when it is finished starting. For example, if you have a program which prints "I am a server, I run now on port 8080", you will have to use
ready 'I am a server, I run now on port 8080'
in the task. You can also just use
ready 'I am a server, I run now on port'
since it will do a "contains".

At leas that was what I did wrong and once I fixed it the plugin worked like a charm.

Here is the relevant code from the plugin itself:

    private boolean waitUntilIsReadyOrEnd(Process process) {
        def line
        def reader = new BufferedReader(new InputStreamReader(process.getInputStream()))
        boolean isReady = false
        while (!isReady && (line = reader.readLine()) != null) {
            logger.quiet line
            runOutputActions(line)
            if (line.contains(ready)) {
                logger.quiet "$command is ready."
                isReady = true
            }
        }
        isReady
    }

HTH

@brendonanderson
Copy link

I also have a similar issue. When using 0.6.0 my tests continue after Spring Boot has started. Using 0.8.0, it just hangs for some amount of time between 2 and 8 minutes, then will continue. No changes other than the version.

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

6 participants