2019-10-03 08:42:09 +02:00
|
|
|
package com.wasteinformationserver;
|
2019-09-20 15:02:17 +02:00
|
|
|
|
2019-12-10 16:43:42 +01:00
|
|
|
import com.wasteinformationserver.basicutils.Info;
|
2019-10-11 11:17:06 +02:00
|
|
|
import com.wasteinformationserver.basicutils.Log;
|
2019-12-01 10:58:43 +01:00
|
|
|
import com.wasteinformationserver.db.JDCB;
|
2020-01-10 18:45:32 +01:00
|
|
|
import com.wasteinformationserver.mqtt.MqttService;
|
2019-10-11 11:17:06 +02:00
|
|
|
import com.wasteinformationserver.website.Webserver;
|
2019-12-13 13:55:32 +01:00
|
|
|
|
2019-12-01 10:58:43 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2019-09-13 15:41:40 +02:00
|
|
|
public class main {
|
|
|
|
public static void main(String[] args) {
|
2020-01-12 11:23:05 +01:00
|
|
|
Log.setLevel(Log.DEBUG);
|
2020-01-13 21:00:33 +01:00
|
|
|
Info.init();
|
2019-10-11 16:14:05 +02:00
|
|
|
|
2020-01-13 21:00:33 +01:00
|
|
|
Log.info("startup of WasteInformationServer");
|
2019-09-27 10:58:13 +02:00
|
|
|
|
2019-12-06 09:24:45 +01:00
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
2019-09-27 16:37:59 +02:00
|
|
|
try {
|
|
|
|
Thread.sleep(200);
|
2019-10-02 21:42:04 +02:00
|
|
|
Log.warning("Shutting down ...");
|
2019-09-27 16:37:59 +02:00
|
|
|
|
|
|
|
//shutdown routine
|
2019-12-06 09:24:45 +01:00
|
|
|
} catch (InterruptedException e) {
|
2019-09-27 16:37:59 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2019-12-13 13:55:32 +01:00
|
|
|
Log.info("Server version: " + Info.getVersion());
|
|
|
|
Log.debug("Build date: " + Info.getBuilddate());
|
2019-12-10 16:43:42 +01:00
|
|
|
|
2019-12-06 09:24:45 +01:00
|
|
|
//initial connect to db
|
2019-12-01 10:58:43 +01:00
|
|
|
Log.message("initial login to db");
|
2020-01-12 13:22:31 +01:00
|
|
|
try {
|
|
|
|
JDCB.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306);
|
|
|
|
//JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
|
|
|
|
} catch (IOException e) {
|
|
|
|
//e.printStackTrace();
|
|
|
|
Log.error("no connection to db");
|
|
|
|
}
|
2019-12-06 09:24:45 +01:00
|
|
|
|
2019-12-06 10:41:36 +01:00
|
|
|
|
2019-12-06 09:24:45 +01:00
|
|
|
//startup web server
|
2019-10-03 08:42:09 +02:00
|
|
|
Thread mythread = new Thread(() -> new Webserver().startserver());
|
2019-11-15 11:23:51 +01:00
|
|
|
mythread.start();
|
2019-09-13 16:48:53 +02:00
|
|
|
|
2019-09-27 10:58:13 +02:00
|
|
|
|
2019-12-01 10:58:43 +01:00
|
|
|
//startup mqtt service
|
|
|
|
Log.message("starting mqtt service");
|
2019-12-06 09:24:45 +01:00
|
|
|
try {
|
2020-01-12 13:22:31 +01:00
|
|
|
MqttService m = new MqttService("mqtt.heili.eu", "1883");
|
2020-01-10 18:45:32 +01:00
|
|
|
m.startupService();
|
2019-12-06 09:24:45 +01:00
|
|
|
} catch (Exception e) {
|
2019-12-13 15:04:53 +01:00
|
|
|
Log.error("An error occured in the class mqtt");
|
2019-11-29 16:55:57 +01:00
|
|
|
}
|
2019-09-13 15:41:40 +02:00
|
|
|
}
|
2019-12-13 16:29:43 +01:00
|
|
|
}
|