这是我开始的代码
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)";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句