aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-07 16:21:46 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-07 16:21:46 -0700
commit081373cf07911939468401a3c1a128ee713052e3 (patch)
treea08787faf131cc5b238d94889fc2cc7b883b62d2
parent71f894ef66fe8ce84eaa32c2771efb53cfd47de4 (diff)
downloadtrackermap-server-081373cf07911939468401a3c1a128ee713052e3.tar.gz
trackermap-server-081373cf07911939468401a3c1a128ee713052e3.tar.bz2
trackermap-server-081373cf07911939468401a3c1a128ee713052e3.zip
Improve debugging experience
-rw-r--r--build.gradle6
-rw-r--r--src/main/java/org/traccar/Main.java13
2 files changed, 15 insertions, 4 deletions
diff --git a/build.gradle b/build.gradle
index 6aa6af8a7..5b7346e20 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,6 +2,7 @@ plugins {
id "java"
id "checkstyle"
id "com.google.protobuf" version "0.8.11"
+ id 'application'
}
repositories {
@@ -19,6 +20,11 @@ ext {
sourceCompatibility = "1.8"
compileJava.options.encoding = "UTF-8"
+application {
+ mainModule = 'tracker-server.main'
+ mainClass = 'org.traccar.Main'
+}
+
checkstyle {
toolVersion = "8.26"
configFile = "gradle/checkstyle.xml" as File
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() {