public void restart ( ) throws RestartNotSupportedException { final Lifecycle lifecycle = restartableLifecycle ( ) ; servletContext . setAttribute ( "app" , new HudsonIsRestarting ( ) ) ; new Thread ( "restart thread" ) { final String exitUser = getAuthentication ( ) . getName ( ) ; @ Override public void run ( ) { try { ACL . impersonate ( ACL . SYSTEM ) ; // give some time for the browser to load the "reloading" page Thread . sleep ( TimeUnit . SECONDS . toMillis ( 5 ) ) ; LOGGER . info ( String . format ( "Restarting VM as requested by %s" , exitUser ) ) ; for ( RestartListener listener : RestartListener . all ( ) ) listener . onRestart ( ) ; lifecycle . restart ( ) ; } catch ( InterruptedException | IOException e ) { LOGGER . log ( Level . WARNING , "Failed to restart Jenkins" , e ) ; } } } . start ( ) ; }
Performs a restart .