Skip to content

Commit

Permalink
KillProcess Task updated to exit gracefully, when the server is not
Browse files Browse the repository at this point in the history
running.
  • Loading branch information
harisingh authored and marc0der committed Nov 21, 2016
1 parent e306214 commit f88c36c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.wiredforcode.gradle.spawn

import org.gradle.api.GradleException
import org.gradle.api.tasks.TaskAction

class KillProcessTask extends DefaultSpawnTask {
@TaskAction
void kill() {
def pidFile = getPidFile()
if(!pidFile.exists()) throw new GradleException("No server running!")
if(!pidFile.exists()) {
logger.quiet "No server running!"
return
}

def pid = pidFile.text
def process = "kill $pid".execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class KillProcessTaskSpec extends Specification {
assert directory.deleteDir()
}

void "should explode if no pid file exists"() {
void "should exit gracefully, if the server is not running"() {
given:
def directoryPath = directory.toString()

Expand All @@ -70,7 +70,7 @@ class KillProcessTaskSpec extends Specification {
killTask.kill()

then:
thrown GradleException
noExceptionThrown()
}

void "should set current directory as default for directory field"() {
Expand Down

0 comments on commit f88c36c

Please sign in to comment.