static public void shutdown ( ) { // need to unregister the service if ( getServerConfig ( ) . enableRegistry && registry != null && serviceUrls != null ) { for ( URL serviceUrl : serviceUrls ) { registry . unregister ( serviceUrl ) ; // Please don't remove the following line. When server is killed, the logback won't work anymore. // Even debugger won't reach this point; however, the logic is executed successfully here. System . out . println ( "unregister serviceUrl " + serviceUrl ) ; if ( logger . isInfoEnabled ( ) ) logger . info ( "unregister serviceUrl " + serviceUrl ) ; } } if ( gracefulShutdownHandler != null ) { logger . info ( "Starting graceful shutdown." ) ; gracefulShutdownHandler . shutdown ( ) ; try { gracefulShutdownHandler . awaitShutdown ( 60 * 1000 ) ; } catch ( InterruptedException e ) { logger . error ( "Error occurred while waiting for pending requests to complete." , e ) ; } logger . info ( "Graceful shutdown complete." ) ; } ShutdownHookProvider [ ] shutdownHookProviders = SingletonServiceFactory . getBeans ( ShutdownHookProvider . class ) ; if ( shutdownHookProviders != null ) Arrays . stream ( shutdownHookProviders ) . forEach ( s -> s . onShutdown ( ) ) ; stop ( ) ; logger . info ( "Cleaning up before server shutdown" ) ; }
implement shutdown hook here .