From 88544e0f367a5ab5a3522ef9cea1f78fda19d7da Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 7 May 2012 17:11:08 +0400 Subject: Added shutdown hook --- default.cfg | 10 +++++----- nbproject/project.properties | 6 +++--- opengts.cfg | 6 +++--- src/Main.java | 14 +++++++++++++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/default.cfg b/default.cfg index 3c432d092..77312d588 100644 --- a/default.cfg +++ b/default.cfg @@ -75,7 +75,7 @@ extended_info - String (XML) <--> - INSERT INTO positions (device_id, time, is_valid, latitude, longitude, speed, course, power) + INSERT INTO positions (device_id, time, valid, latitude, longitude, speed, course, power) VALUES (:device_id, :time, :valid, :latitude, :longitude, :speed, :course, :power) @@ -84,7 +84,7 @@ 8082 - false + true /home/user/Documents/tracker-server.log @@ -123,8 +123,8 @@ 0 - true - 5007 - 0 + true + 5007 + 0 diff --git a/nbproject/project.properties b/nbproject/project.properties index aed63160a..98bd4fb1e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -33,7 +33,7 @@ file.reference.jetty-io-8.1.3.v20120416.jar=/home/user/Documents/lib/jetty/jetty file.reference.jetty-server-8.1.3.v20120416.jar=/home/user/Documents/lib/jetty/jetty-server-8.1.3.v20120416.jar file.reference.jetty-util-8.1.3.v20120416.jar=/home/user/Documents/lib/jetty/jetty-util-8.1.3.v20120416.jar file.reference.junit-4.10.jar=/home/user/Documents/lib/junit-4.10.jar -file.reference.mysql-connector-java-5.1.19-bin.jar=/home/user/Documents/lib/mysql-connector-java-5.1.19-bin.jar +file.reference.mysql-connector-java-5.1.20-bin.jar=/home/user/Documents/lib/mysql-connector-java-5.1.20-bin.jar file.reference.netty-3.4.1.Final.jar=/home/user/Documents/lib/netty-3.4.1.Final.jar file.reference.servlet-api-3.0.jar=/home/user/Documents/lib/jetty/servlet-api-3.0.jar includes=** @@ -42,14 +42,14 @@ jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.netty-3.4.1.Final.jar}:\ - ${file.reference.mysql-connector-java-5.1.19-bin.jar}:\ ${file.reference.h2-1.3.166.jar}:\ ${file.reference.jetty-http-8.1.3.v20120416.jar}:\ ${file.reference.jetty-io-8.1.3.v20120416.jar}:\ ${file.reference.jetty-server-8.1.3.v20120416.jar}:\ ${file.reference.jetty-util-8.1.3.v20120416.jar}:\ ${file.reference.servlet-api-3.0.jar}:\ - ${file.reference.jetty-continuation-8.1.3.v20120416.jar} + ${file.reference.jetty-continuation-8.1.3.v20120416.jar}:\ + ${file.reference.mysql-connector-java-5.1.20-bin.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=true diff --git a/opengts.cfg b/opengts.cfg index 40f535723..11dbbbb2f 100644 --- a/opengts.cfg +++ b/opengts.cfg @@ -84,8 +84,8 @@ 0 - true - 5007 - 0 + true + 5007 + 0 diff --git a/src/Main.java b/src/Main.java index a60d0661f..d8a3b397c 100644 --- a/src/Main.java +++ b/src/Main.java @@ -4,8 +4,20 @@ public class Main { public static void main(String[] args) throws Exception { - Server service = new Server(); + final Server service = new Server(); service.init(args); + + System.out.println("starting server..."); service.start(); + + // Shutdown server properly + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + System.out.println("shutting down server..."); + service.stop(); + } + }); + } } -- cgit v1.2.3