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 --- src/Main.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Main.java') 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