|
|
@ -81,6 +81,7 @@ public class DynamicDockerHook implements AirsonicServer, EnvironmentAware, Init |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
final String name = "airsonic-it-" + RandomStringUtils.randomAlphabetic(10); |
|
|
|
final String name = "airsonic-it-" + RandomStringUtils.randomAlphabetic(10); |
|
|
|
|
|
|
|
boolean isException = false; |
|
|
|
try { |
|
|
|
try { |
|
|
|
final ContainerCreation containerCreate = docker.createContainer(config, name); |
|
|
|
final ContainerCreation containerCreate = docker.createContainer(config, name); |
|
|
|
containerId = containerCreate.id(); |
|
|
|
containerId = containerCreate.id(); |
|
|
@ -109,6 +110,7 @@ public class DynamicDockerHook implements AirsonicServer, EnvironmentAware, Init |
|
|
|
break; |
|
|
|
break; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.trace("Container ("+name+") never became ready within max wait time"); |
|
|
|
logger.trace("Container ("+name+") never became ready within max wait time"); |
|
|
|
|
|
|
|
isException = true; |
|
|
|
throw new RuntimeException("Container ("+name+") not ready"); |
|
|
|
throw new RuntimeException("Container ("+name+") not ready"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -118,10 +120,16 @@ public class DynamicDockerHook implements AirsonicServer, EnvironmentAware, Init |
|
|
|
String ipAddress = next.getValue().ipAddress(); |
|
|
|
String ipAddress = next.getValue().ipAddress(); |
|
|
|
serverUri = "http://" + ipAddress + ":" + dockerPort; |
|
|
|
serverUri = "http://" + ipAddress + ":" + dockerPort; |
|
|
|
} catch(Exception e) { |
|
|
|
} catch(Exception e) { |
|
|
|
|
|
|
|
isException = true; |
|
|
|
throw new RuntimeException("Could not determine container ("+name+") address", e); |
|
|
|
throw new RuntimeException("Could not determine container ("+name+") address", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (DockerException | InterruptedException e) { |
|
|
|
} catch (DockerException | InterruptedException e) { |
|
|
|
|
|
|
|
isException = true; |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
if(isException){ |
|
|
|
|
|
|
|
stopServer(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|