This commit is contained in:
Kent Yao 2020-10-22 14:18:26 +08:00
parent 2f564c6b20
commit 9e2c092fc4
2 changed files with 6 additions and 4 deletions

View File

@ -103,7 +103,7 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab
def connectionUrl: String = s"${serverAddr.getCanonicalHostName}:$portNum"
override def start(): Unit = {
override def start(): Unit = synchronized {
super.start()
if (!isStarted) {
val thread = new Thread(this)
@ -122,7 +122,7 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab
System.exit(-1)
}
override def stop(): Unit = {
override def stop(): Unit = synchronized {
if (isStarted) {
server.foreach(_.stop())
info(this.name + " has stopped")

View File

@ -56,7 +56,7 @@ trait ProcBuilder {
@volatile private var error: Throwable = UNCAUGHT_ERROR
final def start: Process = {
final def start: Process = synchronized {
val procLog = Paths.get(workingDir.toAbsolutePath.toString, s"$module.log")
processBuilder.redirectError(procLog.toFile)
processBuilder.redirectOutput(procLog.toFile)
@ -83,6 +83,8 @@ trait ProcBuilder {
}
} catch {
case _: IOException =>
} finally {
reader.close()
}
}
@ -90,7 +92,7 @@ trait ProcBuilder {
proc
}
def getError: Throwable = {
def getError: Throwable = synchronized {
if (error == UNCAUGHT_ERROR) {
Thread.sleep(3000)
}