Greeting,
I have been working on a Traccar open source application for a while and wonder how could I restart server in my program without any connection error issues. What I have done is stopping program in java with:
System.exit(0);
and then in the run function available in Main class I put these below codes
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
LOGGER.info("Shutting down server...");
Context.getScheduleManager().stop();
if (Context.getWebServer() != null) {
Context.getWebServer().stop();
}
Context.getServerManager().stop();
try {
Thread.sleep(10000);
Main.run("./debug.xml");
} catch (InterruptedException e) {
e.printStackTrace();
}
}));
But when my program is stopped, I will have some errors dedicated to connection.
here is my log file:
2021-11-09 12:24:29 INFO: Shutting down server...
2021-11-09 12:24:39 INFO: HikariPool-2 - Starting...
2021-11-09 12:24:39 INFO: HikariPool-2 - Start completed.
2021-11-09 12:24:39 INFO: Clearing database change log checksums
2021-11-09 12:24:39 INFO: Successfully acquired change log lock
2021-11-09 12:24:39 INFO: Successfully released change log lock
2021-11-09 12:24:39 INFO: Successfully acquired change log lock
2021-11-09 12:24:40 INFO: Reading from traccar2.DATABASECHANGELOG
2021-11-09 12:24:40 INFO: Reading from traccar2.DATABASECHANGELOG
2021-11-09 12:24:40 INFO: Successfully released change log lock
2021-11-09 12:24:40 ERROR: Main method error - NullPointerException (DeviceManager:361 < *:269 < *:41 < BaseObjectManager:97 < *:47 < DeviceManager:57 < ...)
2021-11-09 12:24:40 ERROR: Thread exception - NullPointerException (DeviceManager:361 < *:269 < *:41 < BaseObjectManager:97 < *:47 < DeviceManager:57 < ...)
I would be thankful if you can help me to tackle this problem.
best regards
Greeting,
I have been working on a Traccar open source application for a while and wonder how could I restart server in my program without any connection error issues. What I have done is stopping program in java with:
System.exit(0);
and then in the run function available in Main class I put these below codes
Runtime.getRuntime().addShutdownHook(new Thread(() -> { LOGGER.info("Shutting down server..."); Context.getScheduleManager().stop(); if (Context.getWebServer() != null) { Context.getWebServer().stop(); } Context.getServerManager().stop(); try { Thread.sleep(10000); Main.run("./debug.xml"); } catch (InterruptedException e) { e.printStackTrace(); } }));
But when my program is stopped, I will have some errors dedicated to connection.
here is my log file:
I would be thankful if you can help me to tackle this problem.
best regards