[KYUUBI #1039][FOLLOWUP] Application stop log redirect append to engineLog

### _Why are the changes needed?_
Now application stop log will overwrite log file `engineLog`, which cause engine logs are lost.
![image](https://user-images.githubusercontent.com/18065113/136765514-6a41d2ce-d3df-4b9b-a6d1-5c9bb51a8e4d.png)
This pr change `overwrite` to `append`.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [x] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #1210 from simon824/redirect.

Closes #1039

ae3e031d [simon] Redirect append to engineLog
2d399883 [simon] Merge remote-tracking branch 'upstream/master'
3d9c12d3 [simon] Merge remote-tracking branch 'upstream/master'
5b905dbd [simon] Merge remote-tracking branch 'upstream/master'

Authored-by: simon <zhangshiming@cvte.com>
Signed-off-by: ulysses-you <ulyssesyou@apache.org>
This commit is contained in:
simon 2021-10-12 11:03:16 +08:00 committed by ulysses-you
parent a55d5fbf79
commit 7a77b7da40
No known key found for this signature in database
GPG Key ID: 4C500BC62D576766

View File

@ -18,6 +18,7 @@
package org.apache.kyuubi.engine package org.apache.kyuubi.engine
import java.io.{File, IOException} import java.io.{File, IOException}
import java.lang.ProcessBuilder.Redirect
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path} import java.nio.file.{Files, Path}
@ -164,8 +165,8 @@ trait ProcBuilder {
val pb = new ProcessBuilder("/bin/sh", s"$kyuubiHome/bin/stop-application.sh", appId) val pb = new ProcessBuilder("/bin/sh", s"$kyuubiHome/bin/stop-application.sh", appId)
pb.environment() pb.environment()
.putAll(env.asJava) .putAll(env.asJava)
pb.redirectError(engineLog) pb.redirectError(Redirect.appendTo(engineLog))
pb.redirectOutput(engineLog) pb.redirectOutput(Redirect.appendTo(engineLog))
val process = pb.start() val process = pb.start()
process.waitFor() match { process.waitFor() match {
case id if id != 0 => s"Failed to kill Application $appId, please kill it manually. " case id if id != 0 => s"Failed to kill Application $appId, please kill it manually. "