aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject aries-containers git commit: Initial health check support for docker local binding.
Date Thu, 15 Jun 2017 15:56:46 GMT
Repository: aries-containers
Updated Branches:
  refs/heads/master 4c2f4dddd -> 8c2c7e511


Initial health check support for docker local binding.


Project: http://git-wip-us.apache.org/repos/asf/aries-containers/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-containers/commit/8c2c7e51
Tree: http://git-wip-us.apache.org/repos/asf/aries-containers/tree/8c2c7e51
Diff: http://git-wip-us.apache.org/repos/asf/aries-containers/diff/8c2c7e51

Branch: refs/heads/master
Commit: 8c2c7e51101bb594a0e94efb2a1cc2820ec9c4bb
Parents: 4c2f4dd
Author: David Bosschaert <davidb@apache.org>
Authored: Thu Jun 15 16:56:27 2017 +0100
Committer: David Bosschaert <davidb@apache.org>
Committed: Thu Jun 15 16:56:27 2017 +0100

----------------------------------------------------------------------
 .../local/impl/LocalDockerServiceManager.java    | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-containers/blob/8c2c7e51/containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java
----------------------------------------------------------------------
diff --git a/containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java
b/containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java
index c51484f..6e0f4a2 100644
--- a/containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java
+++ b/containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java
@@ -37,6 +37,7 @@ import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
 import org.apache.aries.containers.Container;
+import org.apache.aries.containers.HealthCheck;
 import org.apache.aries.containers.Service;
 import org.apache.aries.containers.ServiceConfig;
 import org.apache.aries.containers.ServiceManager;
@@ -149,6 +150,24 @@ public class LocalDockerServiceManager implements ServiceManager {
         command.add(config.getContainerImage());
         command.addAll(Arrays.asList(config.getCommandLine()));
 
+        if (config.getHealthChecks().size() > 0) {
+            // Only one healthcheck supported
+            HealthCheck hc = config.getHealthChecks().get(0);
+            if (hc.getType() != HealthCheck.Type.COMMAND) {
+                throw new UnsupportedOperationException("Health check of type " + hc.getType()
+
+                        " not supported. Docker only supports health checks of type COMMAND");
+            }
+
+            command.add("--health-cmd");
+            command.add(hc.getParameters());
+            command.add("--health-interval");
+            command.add(hc.getInterval() + "s");
+            command.add("--health-retries");
+            command.add("" + hc.getMaxFailures());
+            command.add("--health-timeout");
+            command.add(hc.getTimeout() + "s");
+        }
+
         DockerContainerInfo info = docker.run(command);
 
         return new ContainerImpl(info.getID(), info.getIP(), ports);


Mime
View raw message