elasticsearch 在我通过gradle运行后,如何停止弹性?
这是我的代码,我从这里开始elasticsearch 在我通过gradle运行后,如何停止弹性?,elasticsearch,gradle,elasticsearch,Gradle,这是我的代码,我从这里开始 task runElastic(type:Exec, dependsOn: ['taskUnzip']) { workingDir "${buildDir}/unpacked/dist/elasticsearch-7.6.0/bin" if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) { commandLine 'cmd',
task runElastic(type:Exec, dependsOn: ['taskUnzip']) {
workingDir "${buildDir}/unpacked/dist/elasticsearch-7.6.0/bin"
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'elasticsearch.bat'
} else {
commandLine './elasticsearch'
}
}
也许我能找到进程的pid并被它们杀死?我找到了解决方案,
我在港口停
if (OS.contains("windows")) {
killByPort = "cmd /c \"for /f \"tokens=5\" %a in ('netstat -aon ^| find \":9200\" ^| find " +
"\"LISTENING\"') do " +
"taskkill /f /pid %a\"";
} else {
killByPort = "sh -c PATH=$PATH:/usr/sbin && kill -9 $(lsof -t -i:9200)";
}