@@ -318,38 +318,41 @@ public String getName() {
318318
319319 private void launchConsoleProxy (final byte [] ksBits , final String ksPassword ) {
320320 final Object resource = this ;
321-
322- _consoleProxyMain = new Thread (new Runnable () {
323- public void run () {
324- try {
325- Class <?> consoleProxyClazz = Class .forName ("com.cloud.consoleproxy.ConsoleProxy" );
321+ if (_consoleProxyMain == null ) {
322+ _consoleProxyMain = new Thread (new Runnable () {
323+ public void run () {
326324 try {
327- Method method = consoleProxyClazz .getMethod ("startWithContext" , Properties .class , Object .class , byte [].class , String .class );
328- method .invoke (null , _properties , resource , ksBits , ksPassword );
329- } catch (SecurityException e ) {
330- s_logger .error ("Unable to launch console proxy due to SecurityException" );
331- System .exit (ExitStatus .Error .value ());
332- } catch (NoSuchMethodException e ) {
333- s_logger .error ("Unable to launch console proxy due to NoSuchMethodException" );
334- System .exit (ExitStatus .Error .value ());
335- } catch (IllegalArgumentException e ) {
336- s_logger .error ("Unable to launch console proxy due to IllegalArgumentException" );
337- System .exit (ExitStatus .Error .value ());
338- } catch (IllegalAccessException e ) {
339- s_logger .error ("Unable to launch console proxy due to IllegalAccessException" );
340- System .exit (ExitStatus .Error .value ());
341- } catch (InvocationTargetException e ) {
342- s_logger .error ("Unable to launch console proxy due to InvocationTargetException" );
325+ Class <?> consoleProxyClazz = Class .forName ("com.cloud.consoleproxy.ConsoleProxy" );
326+ try {
327+ Method method = consoleProxyClazz .getMethod ("startWithContext" , Properties .class , Object .class , byte [].class , String .class );
328+ method .invoke (null , _properties , resource , ksBits , ksPassword );
329+ } catch (SecurityException e ) {
330+ s_logger .error ("Unable to launch console proxy due to SecurityException" );
331+ System .exit (ExitStatus .Error .value ());
332+ } catch (NoSuchMethodException e ) {
333+ s_logger .error ("Unable to launch console proxy due to NoSuchMethodException" );
334+ System .exit (ExitStatus .Error .value ());
335+ } catch (IllegalArgumentException e ) {
336+ s_logger .error ("Unable to launch console proxy due to IllegalArgumentException" );
337+ System .exit (ExitStatus .Error .value ());
338+ } catch (IllegalAccessException e ) {
339+ s_logger .error ("Unable to launch console proxy due to IllegalAccessException" );
340+ System .exit (ExitStatus .Error .value ());
341+ } catch (InvocationTargetException e ) {
342+ s_logger .error ("Unable to launch console proxy due to InvocationTargetException" );
343+ System .exit (ExitStatus .Error .value ());
344+ }
345+ } catch (final ClassNotFoundException e ) {
346+ s_logger .error ("Unable to launch console proxy due to ClassNotFoundException" );
343347 System .exit (ExitStatus .Error .value ());
344348 }
345- } catch (final ClassNotFoundException e ) {
346- s_logger .error ("Unable to launch console proxy due to ClassNotFoundException" );
347- System .exit (ExitStatus .Error .value ());
348349 }
349- }
350- }, "Console-Proxy-Main" );
351- _consoleProxyMain .setDaemon (true );
352- _consoleProxyMain .start ();
350+ }, "Console-Proxy-Main" );
351+ _consoleProxyMain .setDaemon (true );
352+ _consoleProxyMain .start ();
353+ } else {
354+ s_logger .error ("com.cloud.consoleproxy.ConsoleProxy is already running" );
355+ }
353356 }
354357
355358 public boolean authenticateConsoleAccess (String host , String port , String vmId , String sid , String ticket ) {
0 commit comments