Initial commit
This commit is contained in:
2
src/jvmMain/kotlin/nl/astraeus/vst/chip/Index.kt
Normal file
2
src/jvmMain/kotlin/nl/astraeus/vst/chip/Index.kt
Normal file
@@ -0,0 +1,2 @@
|
||||
package nl.astraeus.vst.chip
|
||||
|
||||
20
src/jvmMain/kotlin/nl/astraeus/vst/chip/Main.kt
Normal file
20
src/jvmMain/kotlin/nl/astraeus/vst/chip/Main.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package nl.astraeus.vst.chip
|
||||
|
||||
import io.undertow.Undertow
|
||||
import io.undertow.UndertowOptions
|
||||
|
||||
fun main() {
|
||||
Thread.setDefaultUncaughtExceptionHandler { _, e ->
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
val server = Undertow.builder()
|
||||
.addHttpListener(Settings.port, "0.0.0.0")
|
||||
.setIoThreads(4)
|
||||
.setHandler(RequestHandler)
|
||||
.setServerOption(UndertowOptions.SHUTDOWN_TIMEOUT, 1000)
|
||||
.build()
|
||||
|
||||
println("Starting server at port ${Settings.port}...")
|
||||
server?.start()
|
||||
}
|
||||
16
src/jvmMain/kotlin/nl/astraeus/vst/chip/RequestHandler.kt
Normal file
16
src/jvmMain/kotlin/nl/astraeus/vst/chip/RequestHandler.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package nl.astraeus.vst.chip
|
||||
|
||||
import io.undertow.server.HttpHandler
|
||||
import io.undertow.server.HttpServerExchange
|
||||
import io.undertow.server.handlers.resource.PathResourceManager
|
||||
import io.undertow.server.handlers.resource.ResourceHandler
|
||||
import java.nio.file.Paths
|
||||
|
||||
object RequestHandler : HttpHandler {
|
||||
val resourceHandler = ResourceHandler(PathResourceManager(Paths.get("web")))
|
||||
|
||||
override fun handleRequest(exchange: HttpServerExchange) {
|
||||
resourceHandler.handleRequest(exchange)
|
||||
}
|
||||
|
||||
}
|
||||
50
src/jvmMain/kotlin/nl/astraeus/vst/chip/Settings.kt
Normal file
50
src/jvmMain/kotlin/nl/astraeus/vst/chip/Settings.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
package nl.astraeus.vst.chip
|
||||
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.util.*
|
||||
|
||||
object Settings {
|
||||
var runningAsRoot: Boolean = false
|
||||
var port = 9000
|
||||
var sslPort = 8443
|
||||
var connectionTimeout = 30000
|
||||
|
||||
var jdbcDriver = "nl.astraeus.jdbc.Driver"
|
||||
var jdbcConnectionUrl = "jdbc:stat:webServerPort=6001:jdbc:sqlite:data/srp.db"
|
||||
var jdbcUser = "sa"
|
||||
var jdbcPassword = ""
|
||||
|
||||
var adminUser = "rnentjes"
|
||||
var adminPassword = "9/SG_Bd}9gWz~?j\\A.U]n9]OO"
|
||||
|
||||
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
|
||||
|
||||
runningAsRoot = properties.getProperty("runningAsRoot", runningAsRoot.toString()).toBoolean()
|
||||
port = properties.getProperty("port", port.toString()).toInt()
|
||||
sslPort = properties.getProperty("sslPort", sslPort.toString()).toInt()
|
||||
connectionTimeout = properties.getProperty("connectionTimeout", connectionTimeout.toString()).toInt()
|
||||
jdbcDriver = properties.getProperty("jdbcDriver", jdbcDriver)
|
||||
jdbcConnectionUrl = properties.getProperty("jdbcConnectionUrl", jdbcConnectionUrl)
|
||||
jdbcUser = properties.getProperty("jdbcUser", jdbcUser)
|
||||
jdbcPassword = properties.getProperty("jdbcPassword", jdbcPassword)
|
||||
|
||||
adminUser = properties.getProperty("adminUser", adminUser)
|
||||
adminPassword = properties.getProperty("adminPassword", adminPassword)
|
||||
}
|
||||
}
|
||||
6
src/jvmMain/resources/index.html
Normal file
6
src/jvmMain/resources/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<script type="application/javascript" src="vst-chip-worklet-ui.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user