From 081373cf07911939468401a3c1a128ee713052e3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 7 Jun 2020 16:21:46 -0700 Subject: Improve debugging experience --- src/main/java/org/traccar/Main.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/Main.java b/src/main/java/org/traccar/Main.java index 47d6e91df..a0d93dbc8 100644 --- a/src/main/java/org/traccar/Main.java +++ b/src/main/java/org/traccar/Main.java @@ -21,6 +21,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.traccar.api.HealthCheckService; +import java.io.File; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.OperatingSystemMXBean; @@ -76,13 +77,17 @@ public final class Main { public static void main(String[] args) throws Exception { Locale.setDefault(Locale.ENGLISH); + final String configFile; if (args.length <= 0) { - throw new RuntimeException("Configuration file is not provided"); + configFile = "./debug.xml"; + if (!new File(configFile).exists()) { + throw new RuntimeException("Configuration file is not provided"); + } + } else { + configFile = args[args.length - 1]; } - final String configFile = args[args.length - 1]; - - if (args[0].startsWith("--")) { + if (args.length > 0 && args[0].startsWith("--")) { WindowsService windowsService = new WindowsService("traccar") { @Override public void run() { -- cgit v1.2.3