<commit_before>package walfie.gbf.raidfinder.server

import akka.actor._
import akka.stream.ActorMaterializer
import com.typesafe.config.ConfigFactory
import java.util.concurrent.TimeUnit
import monix.execution.Scheduler.Implicits.global
import play.api.http.DefaultHttpErrorHandler
import play.api.mvc._
import play.api.routing.Router
import play.api.routing.sird._
import play.api.{BuiltInComponents, Logger, Mode}
import play.core.server._
import play.core.server.NettyServerComponents
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.control.NonFatal
import walfie.gbf.raidfinder
import walfie.gbf.raidfinder.RaidFinder

object Application {
  def main(args: Array[String]): Unit = {
    val raidFinder = RaidFinder.withBacklog()

    val config = ConfigFactory.load()
    val port = config.getInt("http.port")

    val mode = getMode(config.getString("application.mode"))
    val keepAliveInterval = config.getDuration(
      "application.websocket.keepAliveInterval",
      TimeUnit.MILLISECONDS
    ).milliseconds
    val components = new Components(raidFinder, port, mode, keepAliveInterval)
    val server = components.server

    if (mode == Mode.Dev) {
      Logger.info("Press ENTER to stop the application.")
      scala.io.StdIn.readLine()
      server.stop()
    }

    Runtime.getRuntime.addShutdownHook(new Thread() {
      Logger.info("Stopping application.")
      server.stop()
    })
  }

  def getMode(s: String): Mode.Mode = s match {
    case "dev" => Mode.Dev
    case "prod" => Mode.Prod
    case unknown => throw new IllegalArgumentException(
      s"""Unknown application.mode "$unknown" (Must be one of: dev, prod)"""
    )
  }
}
<commit_msg>Don't immediately shut down in prod mode<commit_after>package walfie.gbf.raidfinder.server

import akka.actor._
import akka.stream.ActorMaterializer
import com.typesafe.config.ConfigFactory
import java.util.concurrent.TimeUnit
import monix.execution.Scheduler.Implicits.global
import play.api.http.DefaultHttpErrorHandler
import play.api.mvc._
import play.api.routing.Router
import play.api.routing.sird._
import play.api.{BuiltInComponents, Logger, Mode}
import play.core.server._
import play.core.server.NettyServerComponents
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.control.NonFatal
import walfie.gbf.raidfinder
import walfie.gbf.raidfinder.RaidFinder

object Application {
  def main(args: Array[String]): Unit = {
    val raidFinder = RaidFinder.withBacklog()

    val config = ConfigFactory.load()
    val port = config.getInt("http.port")

    val mode = getMode(config.getString("application.mode"))
    val keepAliveInterval = config.getDuration(
      "application.websocket.keepAliveInterval",
      TimeUnit.MILLISECONDS
    ).milliseconds
    val components = new Components(raidFinder, port, mode, keepAliveInterval)
    val server = components.server

    if (mode == Mode.Dev) {
      Logger.info("Press ENTER to stop the application.")
      scala.io.StdIn.readLine()
      server.stop()
    }

    Runtime.getRuntime.addShutdownHook(new Thread() {
      override def run(): Unit = {
        Logger.info("Stopping application.")
        server.stop()
      }
    })
  }

  def getMode(s: String): Mode.Mode = s match {
    case "dev" => Mode.Dev
    case "prod" => Mode.Prod
    case unknown => throw new IllegalArgumentException(
      s"""Unknown application.mode "$unknown" (Must be one of: dev, prod)"""
    )
  }
}

{'fraction_non_alphanumeric': 0.1087205966724039, 'fraction_numerical': 0.0, 'mean_word_length': 3.8565459610027855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3403467', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1053, 'n_words': 238}