@Override public boolean status(DeployableDescriptor deployableDescriptor) { List<Container> containers = docker.listContainersCmd().exec(); long size = containers .parallelStream() .filter( c -> c.getId().equals(deployableDescriptor.pid()) && c.getStatus().startsWith("Up ")) .collect(Collectors.toList()) .size(); return size == 1; }
@Override public boolean status(DeployableDescriptor deployableDescriptor) { String pid = deployableDescriptor.pid(); if (pid == null) { return false; } try { Process proc = Runtime.getRuntime().exec("ps aux"); InputStream stream = proc.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line; while ((line = reader.readLine()) != null) { if (line.split("\\s+")[1].equals(pid)) { return true; } } } catch (IOException e) { throw new RuntimeException(e); } return false; }