aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Main.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-14 16:46:40 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-14 16:46:40 +1200
commit5d819b2776328e914a26ae011692084e1b614e26 (patch)
tree6b535ea62ca0651a6ae2f6a88f88863f7af24eca /src/org/traccar/Main.java
parentb10824bb5769c4abb93e3451673b88efdfb9d467 (diff)
downloadtrackermap-server-5d819b2776328e914a26ae011692084e1b614e26.tar.gz
trackermap-server-5d819b2776328e914a26ae011692084e1b614e26.tar.bz2
trackermap-server-5d819b2776328e914a26ae011692084e1b614e26.zip
Add Windows service support
Diffstat (limited to 'src/org/traccar/Main.java')
-rw-r--r--src/org/traccar/Main.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java
index fd1f07dca..986731240 100644
--- a/src/org/traccar/Main.java
+++ b/src/org/traccar/Main.java
@@ -67,7 +67,29 @@ public final class Main {
public static void main(String[] args) throws Exception {
Locale.setDefault(Locale.ENGLISH);
- Context.init(args);
+ if (args.length <= 0) {
+ throw new RuntimeException("Configuration file is not provided");
+ }
+
+ String configFile = args[args.length - 1];
+
+ if (args.length > 1) {
+ WindowsService windowsService = new WindowsService("traccar");
+ switch (args[1]) {
+ case "--install":
+ windowsService.install("traccar", null, null, null, null, configFile);
+ return;
+ case "--uninstall":
+ windowsService.uninstall();
+ return;
+ case "--service":
+ default:
+ windowsService.init();
+ break;
+ }
+ }
+
+ Context.init(configFile);
logSystemInfo();
LOGGER.info("Version: " + Context.getAppVersion());
LOGGER.info("Starting server...");