Skip to content

Commit

Permalink
Fix Logger Disconnect (#1563)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd authored Mar 10, 2021
1 parent 8290ded commit 8b023e2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,43 @@ trait ServiceWithActorSystem extends Service {
import scala.jdk.CollectionConverters._
val loggers: java.lang.Iterable[String] =
Seq("akka.event.Logging$StandardOutLogger").asJava
val config = ConfigFactory
.empty()
.withValue("akka.loggers", ConfigValueFactory.fromAnyRef(loggers))
.withValue(
"akka.logging-filter",
ConfigValueFactory.fromAnyRef("akka.event.DefaultLoggingFilter")
)
.withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("WARNING"))
.withValue(
"akka.coordinated-shutdown.run-by-actor-system-terminate",
ConfigValueFactory.fromAnyRef("off")
val config = {
val baseConfig = ConfigFactory
.empty()
.withValue("akka.loggers", ConfigValueFactory.fromAnyRef(loggers))
.withValue(
"akka.logging-filter",
ConfigValueFactory.fromAnyRef("akka.event.DefaultLoggingFilter")
)
.withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("WARNING"))
.withValue(
"akka.coordinated-shutdown.run-by-actor-system-terminate",
ConfigValueFactory.fromAnyRef("off")
)
.withValue("akka.daemonic", ConfigValueFactory.fromAnyRef("on"))
.withValue(
"akka.http.server.websocket.periodic-keep-alive-mode",
ConfigValueFactory.fromAnyRef("ping")
)
.withValue(
"akka.http.server.websocket.periodic-keep-alive-max-idle",
ConfigValueFactory.fromAnyRef("30 seconds")
)

val timeouts = Seq(
"akka.http.server.idle-timeout",
"akka.http.client.idle-timeout",
"akka.http.host-connection-pool.client.idle-timeout",
"akka.http.host-connection-pool.idle-timeout"
)
.withValue("akka.daemonic", ConfigValueFactory.fromAnyRef("on"))
val configWithTimeouts = timeouts.foldLeft(baseConfig) {
case (config, key) =>
config.withValue(key, ConfigValueFactory.fromAnyRef("120 seconds"))
}

configWithTimeouts
}

ActorSystem(
name,
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class FileOutputPrinter(
override def print(message: WSLogMessage): Unit = {
val lines = renderer.render(message)
writer.println(lines)
// TODO [RW] we may consider making flushing configurable as it is mostly
// useful for debugging crashes, whereas for usual usecases buffering could
// give slightly better performance
writer.flush()
}

/** @inheritdoc */
Expand Down

0 comments on commit 8b023e2

Please sign in to comment.