public void activate ( ) { String pidFile = System . getProperty ( "cassandra-pidfile" ) ; try { try { MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; mbs . registerMBean ( new StandardMBean ( new NativeAccess ( ) , NativeAccessMBean . class ) , new ObjectName ( MBEAN_NAME ) ) ; } catch ( Exception e ) { logger . error ( "error registering MBean {}" , MBEAN_NAME , e ) ; //Allow the server to start even if the bean can't be registered } setup ( ) ; if ( pidFile != null ) { new File ( pidFile ) . deleteOnExit ( ) ; } if ( System . getProperty ( "cassandra-foreground" ) == null ) { System . out . close ( ) ; System . err . close ( ) ; } start ( ) ; } catch ( Throwable e ) { logger . error ( "Exception encountered during startup" , e ) ; // try to warn user on stdout too, if we haven't already detached e . printStackTrace ( ) ; System . out . println ( "Exception encountered during startup: " + e . getMessage ( ) ) ; System . exit ( 3 ) ; } }
A convenience method to initialize and start the daemon in one shot .