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