1
0
Fork 0

Use configuration file stonks.config

main
Kevin Belisle 2021-06-30 15:59:27 -04:00
parent a4140f708c
commit a50a8a8ac9
3 changed files with 26 additions and 10 deletions

View File

@ -58,6 +58,8 @@ dependencies {
implementation("joda-time:joda-time:2.10.10")
implementation("com.beust:klaxon:5.5")
implementation("com.natpryce:konfig:1.6.10.0")
}
application {

View File

@ -1,5 +1,8 @@
package xyz.etztech.stonks
import com.natpryce.konfig.*
import java.io.FileInputStream
import java.util.*
import kotlinx.coroutines.*
import org.h2.tools.Server
import org.jetbrains.exposed.exceptions.ExposedSQLException
@ -14,11 +17,19 @@ fun main() =
runBlocking {
println("Starting Stonks...")
val databaseBaseDir = "./databases"
val databaseName = "statistics"
val h2StartWebServer = true
val h2tWebServerPort = 8082
val h2TcpServerPort = 9092
val fis = FileInputStream("./stonks.config")
val config = Properties()
config.load(fis)
val databaseBaseDir = config.getProperty("databaseBaseDir")
val databaseName = config.getProperty("databaseName")
val h2StartWebServer = config.getProperty("h2StartWebServer").toBoolean()
val h2tWebServerPort = config.getProperty("h2tWebServerPort").toInt()
val h2TcpServerPort = config.getProperty("h2TcpServerPort").toInt()
val apiServerPort = config.getProperty("apiServerPort").toInt()
val periodicFetchingInterval = config.getProperty("periodicFetchingInterval").toLong()
val minecraftStatsFolder = config.getProperty("minecraftStatsFolder")
val database =
initH2Server(
@ -28,13 +39,8 @@ fun main() =
h2StartWebServer,
h2tWebServerPort)
val apiServerPort = 7000
initApiServer(apiServerPort, database)
val periodicFetchingInterval = 15 * 60 * 1000L
val minecraftStatsFolder = "../test_data"
initPeriodicFetching(periodicFetchingInterval, minecraftStatsFolder, database)
delay(60 * 1000L)

View File

@ -0,0 +1,8 @@
databaseBaseDir=./databases
databaseName=statistics
h2StartWebServer=true
h2tWebServerPort=8082
h2TcpServerPort=9092
apiServerPort=7000
periodicFetchingInterval=900000
minecraftStatsFolder=../test_data