Skip to content

Commit

Permalink
Adds configuration to proceed if pidFile exists.
Browse files Browse the repository at this point in the history
    - Fixes marc0der#27
    - If the process was killed but the pidFile was not deleted, this
      will proceed without executing command (silent failure).
    - Defaults to previous behavior (fail if pidFile exists)
    - Also changes "Server" to "$command" in exception message.
  • Loading branch information
jhoch committed Feb 11, 2017
1 parent f88c36c commit 49b322d
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.tasks.TaskAction
class SpawnProcessTask extends DefaultSpawnTask {
String command
String ready
boolean strict = true;
List<Closure> outputActions = new ArrayList<Closure>()

@Input
Expand All @@ -31,10 +32,16 @@ class SpawnProcessTask extends DefaultSpawnTask {
}

def pidFile = getPidFile()
if (pidFile.exists()) throw new GradleException("Server already running!")

def process = buildProcess(directory, command)
waitToProcessReadyOrClosed(process)
if (pidFile.exists()) {
if (strict) {
throw new GradleException("$command already running!")
} else {
logger.quiet "$command already running; proceeding."
}
} else {
def process = buildProcess(directory, command)
waitToProcessReadyOrClosed(process)
}
}

private void waitToProcessReadyOrClosed(Process process) {
Expand Down

0 comments on commit 49b322d

Please sign in to comment.