summaryrefslogblamecommitdiff
path: root/crashbox-server/src/main/scala/io/crashbox/ci/Core.scala
blob: 39a1aeccda0b1f1c76283c5fd8084dafcfc6bacd (plain) (tree)
1
2
3
4
5
6
7
8
9

                      


                                                 
                             
                                
                                    
                                 



                                                            
                                                 
                                                                     

                                                             
 

                                             

                       
                                         
                                                 
                              


   
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")
  }

}