61 lines
1.8 KiB
Java
Raw Normal View History

2019-10-03 08:42:09 +02:00
package com.wasteinformationserver;
2019-09-20 15:02:17 +02:00
import com.wasteinformationserver.basicutils.Info;
2019-10-11 11:17:06 +02:00
import com.wasteinformationserver.basicutils.Log;
import com.wasteinformationserver.db.JDCB;
import com.wasteinformationserver.mqtt.mqtt;
2019-10-11 11:17:06 +02:00
import com.wasteinformationserver.website.Webserver;
2019-12-13 13:55:32 +01:00
import java.io.IOException;
2019-09-13 15:41:40 +02:00
public class main {
public static void main(String[] args) {
2019-10-11 16:14:05 +02:00
2019-12-03 21:57:13 +01:00
Log.setLevel(Log.DEBUG);
Log.info("startup of WasteInformationServer");
2019-10-11 16:14:05 +02:00
2019-12-06 09:24:45 +01:00
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Thread.sleep(200);
2019-10-02 21:42:04 +02:00
Log.warning("Shutting down ...");
//shutdown routine
2019-12-06 09:24:45 +01:00
} catch (InterruptedException e) {
e.printStackTrace();
}
}));
Info.init();
2019-12-13 13:55:32 +01:00
Log.info("Server version: " + Info.getVersion());
Log.debug("Build date: " + Info.getBuilddate());
2019-12-06 09:24:45 +01:00
//initial connect to db
Log.message("initial login to db");
2019-12-06 09:24:45 +01:00
new Thread(() -> {
try {
2019-12-13 11:36:26 +01:00
//JDCB.init("users", "admin0", "wasteinformation", "192.168.65.15", 1883);
JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
2019-12-06 09:24:45 +01:00
} catch (IOException e) {
//e.printStackTrace();
Log.error("no connection to db");
}
}).start();
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());
mythread.start();
2019-09-13 16:48:53 +02:00
//startup mqtt service
Log.message("starting mqtt service");
2019-12-06 09:24:45 +01:00
try {
mqtt m = new mqtt();
m.notifymessage();
2019-12-06 09:24:45 +01:00
} catch (Exception e) {
2019-12-06 10:41:36 +01:00
Log.debug("An error was happened in the class mqtt");
}
2019-09-13 15:41:40 +02:00
}
}