Ejemplo n.º 1
0
    def test_heal_containers(self, healthy):
        (client, container1, container2) = TestHealer._init()
        container1 = Mock()

        container2.attrs['State']['Health'] = {
            "Status": "healthy" if healthy else "unhealthy",
        }

        healer = Healer(client)
        healer.heal_containers()

        container1.restart.assert_not_called()
        if healthy:
            container2.restart.assert_not_called()
        else:
            container2.restart.assert_called()
Ejemplo n.º 2
0
import docker
import logging
from time import sleep
from dhealer.healer import Healer

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    logging.info("Starting")

    client = docker.client.from_env()
    logging.info("Connected to docker")
    healer = Healer(client)

    while True:
        logging.info("Heal unhealthy containers")
        healer.heal_containers()
        sleep(5 * 60)