Skip to content

Commit

Permalink
Remove need for application.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
julianmichael committed Feb 12, 2018
1 parent fe05c9c commit 3ef0985
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
5 changes: 0 additions & 5 deletions sample/jvm/src/main/resources/application.conf

This file was deleted.

12 changes: 12 additions & 0 deletions scripts/initSample.scala
Expand Up @@ -5,9 +5,15 @@ import spacro.sample._
import com.amazonaws.services.mturk.model._
import com.amazonaws.services.mturk._
val hitDataService = new InMemoryHITDataService
val interface = "0.0.0.0"
val httpsPort = 8080
val httpPort = 8888
implicit val config = SandboxTaskConfig(
"spacro-sample",
"localhost",
interface,
httpsPort,
httpPort,
hitDataService)
val exp = new SampleExperiment

Expand Down Expand Up @@ -50,7 +56,13 @@ def getActiveHITIds = {
}

def exit = {
// actor system has to be terminated for JVM to be able to terminate properly upon :q
config.actorSystem.terminate
// flush & release logging resources
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.LoggerContext
LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext].stop
System.out.println("Terminated actor system and logging. Type :q to end.")
}

exp.server
16 changes: 7 additions & 9 deletions spacro/jvm/src/main/scala/spacro/tasks/TaskConfig.scala
@@ -1,6 +1,6 @@
package spacro.tasks

import spacro._
import spacro.HITDataService

import akka.actor.ActorSystem

Expand Down Expand Up @@ -71,6 +71,9 @@ object TaskConfig {
case class ProductionTaskConfig(
override val projectName: String,
override val serverDomain: String,
override val interface: String,
override val httpPort: Int,
override val httpsPort: Int,
override val hitDataService: HITDataService
) extends TaskConfig {

Expand All @@ -86,16 +89,15 @@ case class ProductionTaskConfig(
override val isProduction = true

override val actorSystem = ActorSystem("production")
private[this] val akkaConfig = actorSystem.settings.config
override val interface = akkaConfig.getString("app.interface")
override val httpPort = akkaConfig.getInt("app.httpPort")
override val httpsPort = akkaConfig.getInt("app.httpsPort")
}

/** Complete configuration for running on the sandbox. */
case class SandboxTaskConfig(
override val projectName: String,
override val serverDomain: String,
override val interface: String,
override val httpPort: Int,
override val httpsPort: Int,
override val hitDataService: HITDataService
) extends TaskConfig {

Expand All @@ -110,8 +112,4 @@ case class SandboxTaskConfig(
override val isProduction = false

override val actorSystem = ActorSystem("sandbox")
private[this] val akkaConfig = actorSystem.settings.config
override val interface = akkaConfig.getString("app.interface")
override val httpPort = akkaConfig.getInt("app.httpPort")
override val httpsPort = akkaConfig.getInt("app.httpsPort")
}

0 comments on commit 3ef0985

Please sign in to comment.