Last active
January 13, 2018 23:32
-
-
Save InTheCloudDan/a9dadd8d106ddffa5359d3b7f48a8a2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _docker(self, run_config): | |
def poll(self): | |
return True if self.status == "running" else False | |
def running(self): | |
pass | |
client = docker.from_env() | |
container = client.containers.run("s2client-game", ports={'12000': self._port}, detach=True, | |
healthcheck={"test": "netstat -anpt | grep 12000 || exit 1"}) | |
container.poll = MethodType(docker.models.containers.Container, poll) | |
container.running = MethodType(docker.models.containers.Container, running) | |
health = docker.APIClient() | |
for i in range(60): | |
print(i) | |
if health.inspect_container(container.id)['State']['Health']['Status'] == "healthy": | |
break | |
else: | |
time.sleep(1) | |
return container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment