Move stuff in base

This commit is contained in:
2024-08-09 19:54:36 +02:00
parent 8d529b0a45
commit 40ba59e7bd
27 changed files with 1595 additions and 36 deletions

View File

@@ -0,0 +1,44 @@
package nl.astraeus.vst.base
import java.io.File
import java.io.FileInputStream
import java.util.*
object Settings {
var port = 9004
var connectionTimeout = 30000
var jdbcStatsPort = 6001
var jdbcDriver = "nl.astraeus.jdbc.Driver"
val jdbcConnectionUrl
get() = "jdbc:stat:webServerPort=$jdbcStatsPort:jdbc:sqlite:data/vst.db"
var jdbcUser = "sa"
var jdbcPassword = ""
fun getPropertiesFromFile(filename: String): Properties? {
val propertiesFile = File(filename)
return if (propertiesFile.exists()) {
val properties = Properties()
FileInputStream(propertiesFile).use {
properties.load(it)
}
properties
} else {
null
}
}
fun readProperties(args: Array<String>) {
val filename = if (args.isNotEmpty()) args[0] else "srp.properties"
val properties =
getPropertiesFromFile(filename) ?: return // return if properties couldn't be loaded
port = properties.getProperty("port", port.toString()).toInt()
jdbcStatsPort = properties.getProperty("jdbcStatsPort", jdbcStatsPort.toString()).toInt()
connectionTimeout =
properties.getProperty("connectionTimeout", connectionTimeout.toString()).toInt()
jdbcDriver = properties.getProperty("jdbcDriver", jdbcDriver)
jdbcUser = properties.getProperty("jdbcUser", jdbcUser)
jdbcPassword = properties.getProperty("jdbcPassword", jdbcPassword)
}
}