def main()

in project_restorer/src/main/scala/Main.scala [56:114]


  def main(args:Array[String]):Unit = {

    implicit val matrixStore = new MXSConnectionBuilderImpl(
      hosts = matrixStoreConfig.hosts,
      accessKeyId = matrixStoreConfig.accessKeyId,
      accessKeySecret = matrixStoreConfig.accessKeySecret,
      clusterId = matrixStoreConfig.clusterId,
      maxIdleSeconds = connectionIdleTime
    )
    implicit lazy val vidispineCommunicator = new VidispineCommunicator(vidispineConfig)

    val assetFolderLookup = new AssetFolderLookup(plutoConfig)

    val config = Seq(
      ProcessorConfiguration(
        "pluto-core",
        "core.project.#",
        "storagetier.restorer",
        new PlutoCoreMessageProcessor(matrixStoreConfig, assetFolderLookup)
      )
    )

    MessageProcessingFramework(
      "storagetier-project-restorer",
      OUTPUT_EXCHANGE_NAME,
      "pluto.storagetier.project-restorer",
      "storagetier-project-restorer-retry",
      "storagetier-project-restorer-fail",
      "storagetier-project-restorer-dlq",
      config,
      maximumRetryLimit = retryLimit

    ) match {
      case Left(err) =>
        logger.error(s"Could not initiate message processing framework: $err")
      case Right(framework) =>
        val terminationHandler = new SignalHandler {
          override def handle(signal: Signal): Unit = {
            logger.info(s"Caught signal $signal, terminating")
            framework.terminate()
          }

        }
        Signal.handle(new Signal("INT"), terminationHandler)
        Signal.handle(new Signal("HUP"), terminationHandler)
        Signal.handle(new Signal("TERM"), terminationHandler)

        framework.run().onComplete({
          case Success(_) =>
            logger.info(s"framework run completed")
            Await.ready(actorSystem.terminate(), 10.minutes)
            sys.exit(0)
          case Failure(err) =>
            logger.info(s"framework run failed: ${err.getMessage}", err)
            Await.ready(actorSystem.terminate(), 10.minutes)
            sys.exit(1)
        })
    }
  }