mirror of
https://github.com/enso-org/enso.git
synced 2024-12-18 07:42:21 +03:00
Fix Logging Service Preventing Normal Shutdown (#1377)
This commit is contained in:
parent
9083b90c52
commit
322a967cda
@ -0,0 +1,7 @@
|
||||
package org.enso.loggingservice
|
||||
|
||||
case class LoggingServiceAlreadyInitializedException()
|
||||
extends RuntimeException(
|
||||
"The logging service was already initialized. " +
|
||||
"If it should be restarted, it should be torn down first."
|
||||
)
|
@ -1,7 +1,7 @@
|
||||
package org.enso.loggingservice
|
||||
|
||||
import org.enso.loggingservice.internal.service.{Client, Local, Server, Service}
|
||||
import org.enso.loggingservice.internal._
|
||||
import org.enso.loggingservice.internal.service.{Client, Local, Server, Service}
|
||||
import org.enso.loggingservice.printers.{Printer, StderrPrinter}
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
@ -168,9 +168,7 @@ object LoggingServiceManager {
|
||||
): InitializationResult = {
|
||||
this.synchronized {
|
||||
if (currentService.isDefined) {
|
||||
throw new IllegalStateException(
|
||||
"The logging service has already been set up."
|
||||
)
|
||||
throw new LoggingServiceAlreadyInitializedException()
|
||||
}
|
||||
|
||||
val (service, result): (Service, InitializationResult) = mode match {
|
||||
|
@ -11,8 +11,8 @@ import org.enso.loggingservice.printers.{
|
||||
StderrPrinterWithColors
|
||||
}
|
||||
|
||||
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
|
||||
import scala.concurrent.duration.DurationInt
|
||||
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
|
||||
import scala.util.control.NonFatal
|
||||
import scala.util.{Failure, Success}
|
||||
|
||||
@ -145,6 +145,12 @@ abstract class LoggingServiceSetupHelper(implicit
|
||||
LoggingServiceManager
|
||||
.setup(LoggerMode.Server(createPrinters()), logLevel)
|
||||
.onComplete {
|
||||
case Failure(LoggingServiceAlreadyInitializedException()) =>
|
||||
logger.warn(
|
||||
"Failed to initialize the logger because the logging service " +
|
||||
"was already initialized."
|
||||
)
|
||||
loggingServiceEndpointPromise.trySuccess(None)
|
||||
case Failure(exception) =>
|
||||
logger.error(
|
||||
s"Failed to initialize the logging service server: $exception",
|
||||
@ -158,6 +164,12 @@ abstract class LoggingServiceSetupHelper(implicit
|
||||
logLevel
|
||||
)
|
||||
.onComplete {
|
||||
case Failure(LoggingServiceAlreadyInitializedException()) =>
|
||||
logger.warn(
|
||||
"Failed to initialize the fallback logger because the " +
|
||||
"logging service was already initialized."
|
||||
)
|
||||
loggingServiceEndpointPromise.trySuccess(None)
|
||||
case Failure(fallbackException) =>
|
||||
System.err.println(
|
||||
s"Failed to initialize the fallback logger: " +
|
||||
|
@ -40,7 +40,7 @@ trait ServiceWithActorSystem extends Service {
|
||||
val loggers: java.lang.Iterable[String] =
|
||||
Seq("akka.event.Logging$StandardOutLogger").asJava
|
||||
val config = ConfigFactory
|
||||
.load()
|
||||
.empty()
|
||||
.withValue("akka.loggers", ConfigValueFactory.fromAnyRef(loggers))
|
||||
.withValue(
|
||||
"akka.logging-filter",
|
||||
@ -51,6 +51,7 @@ trait ServiceWithActorSystem extends Service {
|
||||
"akka.coordinated-shutdown.run-by-actor-system-terminate",
|
||||
ConfigValueFactory.fromAnyRef("off")
|
||||
)
|
||||
.withValue("akka.daemonic", ConfigValueFactory.fromAnyRef("on"))
|
||||
ActorSystem(
|
||||
name,
|
||||
config,
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.enso.loggingservice.internal.service
|
||||
|
||||
import org.enso.loggingservice.LogLevel
|
||||
import org.enso.loggingservice.internal.protocol.WSLogMessage
|
||||
import org.enso.loggingservice.internal.{
|
||||
BlockingConsumerMessageQueue,
|
||||
InternalLogger
|
||||
}
|
||||
import org.enso.loggingservice.internal.protocol.WSLogMessage
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
@ -47,6 +47,8 @@ trait ThreadProcessingService extends Service {
|
||||
}
|
||||
|
||||
val thread = new Thread(() => runQueue())
|
||||
thread.setName("logging-service-processing-thread")
|
||||
thread.setDaemon(true)
|
||||
queueThread = Some(thread)
|
||||
thread.start()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user