50 lines
1.4 KiB
Kotlin
Raw Normal View History

@file:JvmName("Main")
2020-01-31 09:17:12 +01:00
package com.wasteinformationserver
import com.wasteinformationserver.basicutils.Info
import com.wasteinformationserver.basicutils.Log
import com.wasteinformationserver.db.JDBC
import com.wasteinformationserver.mqtt.MqttService
import com.wasteinformationserver.website.Webserver
import java.io.IOException
fun main() {
2020-01-31 09:37:06 +01:00
Log.setLevel(Log.DEBUG)
2020-01-31 09:17:12 +01:00
Info.init()
2020-01-31 09:37:06 +01:00
Log.info("startup of WasteInformationServer")
2020-01-31 09:17:12 +01:00
Runtime.getRuntime().addShutdownHook(Thread(Runnable {
try {
Thread.sleep(200)
2020-01-31 09:37:06 +01:00
Log.warning("Shutting down ...")
2020-01-31 09:17:12 +01:00
//shutdown routine
} catch (e: InterruptedException) {
e.printStackTrace()
}
}))
2020-01-31 09:37:06 +01:00
Log.info("Server version: " + Info.getVersion())
Log.debug("Build date: " + Info.getBuilddate())
2020-01-31 09:17:12 +01:00
//initial connect to db
2020-01-31 09:37:06 +01:00
Log.message("initial login to db")
2020-01-31 09:17:12 +01:00
try {
JDBC.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306)
//JDBC.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
} catch (e: IOException) { //e.printStackTrace();
2020-01-31 09:37:06 +01:00
Log.error("no connection to db")
2020-01-31 09:17:12 +01:00
}
//startup web server
val mythread = Thread(Runnable { Webserver().startserver() })
mythread.start()
//startup mqtt service
2020-01-31 09:37:06 +01:00
Log.message("starting mqtt service")
2020-01-31 09:17:12 +01:00
val m = MqttService("mqtt.heili.eu", "1883")
m.startupService()
}