Added shutdown hook

This commit is contained in:
Anton Tananaev 2012-05-07 17:11:08 +04:00
parent f1096076fd
commit 88544e0f36
4 changed files with 24 additions and 12 deletions

View File

@ -75,7 +75,7 @@
extended_info - String (XML)
<-->
<entry key="database.insertPosition">
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)
</entry>
@ -84,7 +84,7 @@
<entry key="http.port">8082</entry>
<!-- Logging options -->
<entry key="logger.enable">false</entry>
<entry key="logger.enable">true</entry>
<entry key="logger.file">/home/user/Documents/tracker-server.log</entry>
<!-- Xexun server configuration -->
@ -123,8 +123,8 @@
<entry key="xexun2.resetDelay">0</entry>
<!-- AVL-08 server configuration -->
<entry key="xexun2.enable">true</entry>
<entry key="xexun2.port">5007</entry>
<entry key="xexun2.resetDelay">0</entry>
<entry key="avl08.enable">true</entry>
<entry key="avl08.port">5007</entry>
<entry key="avl08.resetDelay">0</entry>
</properties>

View File

@ -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

View File

@ -84,8 +84,8 @@
<entry key="xexun2.resetDelay">0</entry>
<!-- AVL-08 server configuration -->
<entry key="xexun2.enable">true</entry>
<entry key="xexun2.port">5007</entry>
<entry key="xexun2.resetDelay">0</entry>
<entry key="avl08.enable">true</entry>
<entry key="avl08.port">5007</entry>
<entry key="avl08.resetDelay">0</entry>
</properties>

View File

@ -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();
}
});
}
}