aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/Main.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-06-14 21:08:21 -0600
committerIván Ávalos <avalos@disroot.org>2024-06-14 21:08:21 -0600
commit471dc4ca7b6cfd656cc2c04c526fe56ee538991c (patch)
tree4766fa7209e2eaab65269db456cf0436e6a64a49 /src/main/java/org/traccar/Main.java
parent447c7e15fcec8fc72d0457bb7dbf166cbea84acd (diff)
parent64528b96da4a742070d5845a876b07ca66ad0be3 (diff)
downloadtrackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.tar.gz
trackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.tar.bz2
trackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.zip
Merge tag 'v6.2'
Diffstat (limited to 'src/main/java/org/traccar/Main.java')
-rw-r--r--src/main/java/org/traccar/Main.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/Main.java b/src/main/java/org/traccar/Main.java
index 33fcf654f..a22194d9e 100644
--- a/src/main/java/org/traccar/Main.java
+++ b/src/main/java/org/traccar/Main.java
@@ -17,6 +17,7 @@ package org.traccar;
import com.google.inject.Guice;
import com.google.inject.Injector;
+import com.google.inject.ProvisionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.broadcast.BroadcastService;
@@ -51,23 +52,22 @@ public final class Main {
public static void logSystemInfo() {
try {
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
- LOGGER.info("Operating system"
- + " name: " + operatingSystemBean.getName()
- + " version: " + operatingSystemBean.getVersion()
- + " architecture: " + operatingSystemBean.getArch());
+ LOGGER.info(
+ "Operating system name: {} version: {} architecture: {}",
+ operatingSystemBean.getName(), operatingSystemBean.getVersion(), operatingSystemBean.getArch());
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
- LOGGER.info("Java runtime"
- + " name: " + runtimeBean.getVmName()
- + " vendor: " + runtimeBean.getVmVendor()
- + " version: " + runtimeBean.getVmVersion());
+ LOGGER.info(
+ "Java runtime name: {} vendor: {} version: {}",
+ runtimeBean.getVmName(), runtimeBean.getVmVendor(), runtimeBean.getVmVersion());
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
- LOGGER.info("Memory limit"
- + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb"
- + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb");
+ LOGGER.info(
+ "Memory limit heap: {}mb non-heap: {}mb",
+ memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024),
+ memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024));
- LOGGER.info("Character encoding: " + Charset.defaultCharset().displayName());
+ LOGGER.info("Character encoding: {}", Charset.defaultCharset().displayName());
} catch (Exception error) {
LOGGER.warn("Failed to get system info");
@@ -115,7 +115,7 @@ public final class Main {
try {
injector = Guice.createInjector(new MainModule(configFile), new DatabaseModule(), new WebModule());
logSystemInfo();
- LOGGER.info("Version: " + Main.class.getPackage().getImplementationVersion());
+ LOGGER.info("Version: {}", Main.class.getPackage().getImplementationVersion());
LOGGER.info("Starting server...");
var services = new ArrayList<LifecycleObject>();
@@ -142,8 +142,14 @@ public final class Main {
}
}));
} catch (Exception e) {
- LOGGER.error("Main method error", e);
- throw new RuntimeException(e);
+ Throwable unwrapped;
+ if (e instanceof ProvisionException) {
+ unwrapped = e.getCause();
+ } else {
+ unwrapped = e;
+ }
+ LOGGER.error("Main method error", unwrapped);
+ System.exit(1);
}
}