outposts: set restart-policy on docker container
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		| @ -71,6 +71,7 @@ class DockerController(BaseController): | |||||||
|                 }, |                 }, | ||||||
|                 "environment": self._get_env(), |                 "environment": self._get_env(), | ||||||
|                 "labels": self._get_labels(), |                 "labels": self._get_labels(), | ||||||
|  |                 "restart_policy": {"Name": "unless-stopped"}, | ||||||
|             } |             } | ||||||
|             if settings.TEST: |             if settings.TEST: | ||||||
|                 del container_args["ports"] |                 del container_args["ports"] | ||||||
| @ -93,14 +94,24 @@ class DockerController(BaseController): | |||||||
|                         has=version, |                         has=version, | ||||||
|                         should=__version__, |                         should=__version__, | ||||||
|                     ) |                     ) | ||||||
|                     container.kill() |                     self.down() | ||||||
|                     container.remove(force=True) |  | ||||||
|                     return self.up() |                     return self.up() | ||||||
|             # Check that container values match our values |             # Check that container values match our values | ||||||
|             if self._comp_env(container): |             if self._comp_env(container): | ||||||
|                 self.logger.info("Container has outdated config, re-creating...") |                 self.logger.info("Container has outdated config, re-creating...") | ||||||
|                 container.kill() |                 self.down() | ||||||
|                 container.remove(force=True) |                 return self.up() | ||||||
|  |             if ( | ||||||
|  |                 container.attrs.get("HostConfig", {}) | ||||||
|  |                 .get("RestartPolicy", {}) | ||||||
|  |                 .get("Name", "") | ||||||
|  |                 .lower() | ||||||
|  |                 != "unless-stopped" | ||||||
|  |             ): | ||||||
|  |                 self.logger.info( | ||||||
|  |                     "Container has mis-matched restart policy, re-creating..." | ||||||
|  |                 ) | ||||||
|  |                 self.down() | ||||||
|                 return self.up() |                 return self.up() | ||||||
|             # Check that container is healthy |             # Check that container is healthy | ||||||
|             if ( |             if ( | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer