2019-10-03 08:42:09 +02:00
|
|
|
package com.wasteinformationserver;
|
2019-09-20 15:02:17 +02:00
|
|
|
|
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;
|
2019-10-04 16:52:14 +02:00
|
|
|
import com.wasteinformationserver.mqtt.*;
|
2019-10-11 11:17:06 +02:00
|
|
|
import com.wasteinformationserver.website.Webserver;
|
2019-10-11 10:48:04 +02: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) {
|
2019-10-11 16:14:05 +02:00
|
|
|
|
2019-12-03 21:57:13 +01:00
|
|
|
Log.setLevel(Log.DEBUG);
|
2019-10-11 16:14:05 +02:00
|
|
|
|
2019-09-27 10:58:13 +02:00
|
|
|
|
2019-11-11 14:28:21 +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
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2019-12-01 10:58:43 +01:00
|
|
|
//initial connect to db
|
|
|
|
Log.message("initial login to db");
|
|
|
|
new Thread(() -> {
|
|
|
|
try {
|
|
|
|
JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation","192.168.65.15",3306);
|
|
|
|
} catch (IOException e) {
|
|
|
|
//e.printStackTrace();
|
|
|
|
Log.error("no connection to db");
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
//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-11-29 16:55:57 +01:00
|
|
|
try{
|
|
|
|
mqtt m = new mqtt();
|
|
|
|
m.notifymessage();
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:58:13 +02:00
|
|
|
|
2019-09-13 15:41:40 +02:00
|
|
|
}
|
|
|
|
}
|