@ SuppressFBWarnings ( "DM_EXIT" ) public void run ( ) { status = CroquetStatus . STARTING ; // create the injector createInjector ( ) ; // configure the Jetty server jettyServer = configureJetty ( settings . getPort ( ) ) ; // add a life-cycle listener to remove drop the PID jettyServer . addLifeCycleListener ( new AbstractLifeCycleListener ( ) { @ Override public void lifeCycleStarted ( final LifeCycle event ) { final String pidFile = settings . getPidFile ( ) ; // when a pid-file is configured, drop it upon successfully binding to the port. if ( pidFile != null ) { LOG . info ( "Dropping PID file: {}" , pidFile ) ; // the PidManager will automatically remove the pid file on shutdown new PidManager ( pidFile ) . dropPidOrDie ( ) ; } else { LOG . warn ( "No PID file specified, so not file will be dropped. " + "Set a file via code or in the config file to drop a pid file." ) ; } } } ) ; // start the server try { jettyServer . start ( ) ; //CHECKSTYLE:OFF the only exception that is thrown } catch ( final Exception e ) { //CHECKSTYLE:ON LOG . error ( "Error starting Jetty: {}" , e . getMessage ( ) , e ) ; System . err . println ( "Error starting Jetty: " + e . getMessage ( ) ) ; System . exit ( - 1 ) ; throw new RuntimeException ( e ) ; // throw this so the whole app stops } // create and start the modules final List < ManagedModule > managedModuleInstances = createAndStartModules ( ) ; // install the shutdown hook Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { @ Override public void run ( ) { status = CroquetStatus . STOPPING ; try { jettyServer . stop ( ) ; //CHECKSTYLE:OFF the only exception that is thrown } catch ( final Exception e ) { //CHECKSTYLE:ON LOG . error ( "Error stopping Jetty: {}" , e . getMessage ( ) , e ) ; } // go through the modules stopping them for ( final ManagedModule module : managedModuleInstances ) { module . stop ( ) ; } status = CroquetStatus . STOPPED ; LOG . info ( "Croquet has stopped" ) ; } } ) ; status = CroquetStatus . RUNNING ; LOG . info ( "Croquet is running on port {}" , settings . getPort ( ) ) ; }
Starts the Croquet framework .