查看dubbo文檔,Dubbo是經過JDK的ShutdownHook來完成優雅停機的:
http://dubbo.io/User+Guide-zh.htm#UserGuide-zh-%E4%BC%98%E9%9B%85%E5%81%9C%E6%9C%BA ide
但能實現優雅停機的前提是,在啓動時,須要指定參數-Ddubbo.shutdown.hook=true: ui
com.alibaba.dubbo.container.Main.main源碼: .net
if ("true".equals(System.getProperty(SHUTDOWN_HOOK_KEY))) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { for (Container container : containers) { try { container.stop(); logger.info("Dubbo " + container.getClass().getSimpleName() + " stopped!"); } catch (Throwable t) { logger.error(t.getMessage(), t); } synchronized (Main.class) { running = false; Main.class.notify(); } } } }); } htm
http://ask.csdn.net/questions/181901 文檔