From 44bbc13b88b2d0aed117178e9dc5da7cab4246ee Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 17 Oct 2016 11:30:06 +0200 Subject: HONEYCOMB-157: fix honeycomb-kill script Change-Id: I10c5446d17cecec00188dc69389bbc85c90ce652 Signed-off-by: Marek Gradzki --- .../fd/honeycomb/common/scripts/StartupScriptGenerator.groovy | 10 ++++++---- common/common-scripts/src/main/resources/scripts/killScript | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/StartupScriptGenerator.groovy b/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/StartupScriptGenerator.groovy index 65245b2e0..566a90d1f 100644 --- a/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/StartupScriptGenerator.groovy +++ b/common/common-scripts/src/main/groovy/io/fd/honeycomb/common/scripts/StartupScriptGenerator.groovy @@ -55,14 +55,15 @@ class StartupScriptGenerator { def debugJvmParameters = properties.getOrDefault(JVM_DEBUG_PARAMS_KEY, DEFAULT_DEBUG_JVM_PARAMS) log.debug "Debug JVM properties: ${additionalJvmParameters}" - def jvmParameters = "${additionalJvmParameters} -jar \$(dirname \$0)/${project.artifactId}-${project.version}.jar" + def jarName = "${project.artifactId}-${project.version}.jar" + def jvmParameters = "${additionalJvmParameters} -jar \$(dirname \$0)/${jarName}" def scriptParent = Paths.get(project.build.outputDirectory, MINIMAL_RESOURCES_FOLDER) scriptParent.toFile().mkdirs() def startScriptPath = generateStartupScript(jvmParameters, log, scriptParent, scriptTemplate) def forkScriptPath = generateForkingStartupScript(scriptParent, log) def debugScriptPath = generateDebugStartupScript(debugJvmParameters, jvmParameters, log, scriptParent, scriptTemplate) - def killScriptPath = generateKillScript(log, scriptParent) + def killScriptPath = generateKillScript(jarName, log, scriptParent) generateReadme(scriptParent, log, startScriptPath, forkScriptPath, debugScriptPath, killScriptPath, project) } @@ -111,9 +112,10 @@ class StartupScriptGenerator { flushScript(scriptPath, new SimpleTemplateEngine().createTemplate(scriptTemplate).make(["exec": exec]).toString()) } - private static def generateKillScript(log, scriptParent) { + private static def generateKillScript(jarName, log, scriptParent) { + def pattern = "java.*${jarName}" def scriptPath = Paths.get(scriptParent.toString(), KILL_SCRIPT_NAME) log.info "Writing kill script to ${scriptPath}" - flushScript(scriptPath, new SimpleTemplateEngine().createTemplate(KILL_SCRIPT_TEMPLATE).make().toString()) + flushScript(scriptPath, new SimpleTemplateEngine().createTemplate(KILL_SCRIPT_TEMPLATE).make(["pattern": pattern]).toString()) } } diff --git a/common/common-scripts/src/main/resources/scripts/killScript b/common/common-scripts/src/main/resources/scripts/killScript index a32aaa6b6..b7fe0ec8b 100644 --- a/common/common-scripts/src/main/resources/scripts/killScript +++ b/common/common-scripts/src/main/resources/scripts/killScript @@ -1,2 +1,2 @@ #!/bin/sh - -kill `ps aux | grep 'java.*honeycomb' | awk '{print \$2}' \ No newline at end of file +kill `ps aux | grep '${pattern}' | grep -v grep | awk '{print \$2}'` \ No newline at end of file -- cgit 1.2.3-korg