Fix serverStart for canceling build to stop server
Dieser Commit ist enthalten in:
Ursprung
d172aacde0
Commit
10db07e075
36
build.gradle
36
build.gradle
@ -130,25 +130,35 @@ def serverStart(String serverName) {
|
|||||||
Thread outputThread = proc.consumeProcessOutputStream(System.out)
|
Thread outputThread = proc.consumeProcessOutputStream(System.out)
|
||||||
outputThread.setName("${serverName} - OutputThread")
|
outputThread.setName("${serverName} - OutputThread")
|
||||||
|
|
||||||
Thread inputThread = new Thread(new Runnable() {
|
Thread inputThread = new Thread({
|
||||||
@Override
|
Reader reader = System.in.newReader()
|
||||||
void run() {
|
Writer writer = proc.getOutputStream().newWriter()
|
||||||
Reader reader = System.in.newReader()
|
try {
|
||||||
Writer writer = proc.getOutputStream().newWriter()
|
while (proc.alive) {
|
||||||
try {
|
String s = reader.readLine()
|
||||||
while (true) {
|
writer.write(s + "\n")
|
||||||
String s = reader.readLine()
|
writer.flush()
|
||||||
writer.write(s + "\n")
|
|
||||||
writer.flush()
|
|
||||||
}
|
|
||||||
} catch (InterruptedIOException e) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignored
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
inputThread.setName("${serverName} - InputThread")
|
inputThread.setName("${serverName} - InputThread")
|
||||||
inputThread.start()
|
inputThread.start()
|
||||||
|
|
||||||
|
gradle.buildFinished { buildResult ->
|
||||||
|
if (!proc.alive) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Writer writer = proc.getOutputStream().newWriter()
|
||||||
|
writer.write("stop\n")
|
||||||
|
writer.flush()
|
||||||
|
|
||||||
|
proc.closeStreams()
|
||||||
|
outputThread.interrupt()
|
||||||
|
inputThread.interrupt()
|
||||||
|
}
|
||||||
|
|
||||||
while (proc.alive) {
|
while (proc.alive) {
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren