bug 11137: don't start HTTP listen if it is already started

This commit is contained in:
Kelven Yang 2011-08-15 18:56:15 -07:00
parent 11d06f3d6a
commit 085bd36035

View File

@ -318,38 +318,41 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword) { private void launchConsoleProxy(final byte[] ksBits, final String ksPassword) {
final Object resource = this; final Object resource = this;
if(_consoleProxyMain == null) {
_consoleProxyMain = new Thread(new Runnable() { _consoleProxyMain = new Thread(new Runnable() {
public void run() { public void run() {
try {
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
try { try {
Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class); Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
method.invoke(null, _properties, resource, ksBits, ksPassword); try {
} catch (SecurityException e) { Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class);
s_logger.error("Unable to launch console proxy due to SecurityException"); method.invoke(null, _properties, resource, ksBits, ksPassword);
System.exit(ExitStatus.Error.value()); } catch (SecurityException e) {
} catch (NoSuchMethodException e) { s_logger.error("Unable to launch console proxy due to SecurityException");
s_logger.error("Unable to launch console proxy due to NoSuchMethodException"); System.exit(ExitStatus.Error.value());
System.exit(ExitStatus.Error.value()); } catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) { s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
s_logger.error("Unable to launch console proxy due to IllegalArgumentException"); System.exit(ExitStatus.Error.value());
System.exit(ExitStatus.Error.value()); } catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) { s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
s_logger.error("Unable to launch console proxy due to IllegalAccessException"); System.exit(ExitStatus.Error.value());
System.exit(ExitStatus.Error.value()); } catch (IllegalAccessException e) {
} catch (InvocationTargetException e) { s_logger.error("Unable to launch console proxy due to IllegalAccessException");
s_logger.error("Unable to launch console proxy due to InvocationTargetException"); System.exit(ExitStatus.Error.value());
} catch (InvocationTargetException e) {
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
System.exit(ExitStatus.Error.value());
}
} catch (final ClassNotFoundException e) {
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
System.exit(ExitStatus.Error.value()); System.exit(ExitStatus.Error.value());
} }
} catch (final ClassNotFoundException e) {
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
System.exit(ExitStatus.Error.value());
} }
} }, "Console-Proxy-Main");
}, "Console-Proxy-Main"); _consoleProxyMain.setDaemon(true);
_consoleProxyMain.setDaemon(true); _consoleProxyMain.start();
_consoleProxyMain.start(); } else {
s_logger.error("com.cloud.consoleproxy.ConsoleProxy is already running");
}
} }
public boolean authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket) { public boolean authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket) {