summaryrefslogtreecommitdiff
path: root/crashbox-server/src/main/scala/io/crashbox/ci/Core.scala
blob: 39a1aeccda0b1f1c76283c5fd8084dafcfc6bacd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package io.crashbox.ci

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration.Duration

import akka.actor.ActorSystem
import akka.event.LoggingAdapter
import akka.stream.ActorMaterializer
import com.typesafe.config.Config

trait Core {

  implicit val system: ActorSystem = ActorSystem("crashbox")
  implicit val materializer = ActorMaterializer()
  implicit val executionContext: ExecutionContext = system.dispatcher
  val blockingDispatcher: ExecutionContext =
    system.dispatchers.lookup("crashbox.blocking-dispatcher")

  def log: LoggingAdapter = system.log
  def config: Config = system.settings.config

  sys.addShutdownHook {
    log.info("Shutting down core system")
    Await.ready(system.terminate(), Duration.Inf)
    log.info("System stopped")
  }

}