add recreate

This commit is contained in:
2026-01-01 11:53:25 -08:00
parent ef86a101bd
commit e5ecf16127
3 changed files with 19 additions and 2 deletions

0
composer-lens/app.py Normal file
View File

View File

View File

@@ -136,7 +136,7 @@ class Composer:
"""Sets the running status of the compose stack """Sets the running status of the compose stack
Args: Args:
status: string containing "up", "down", or "restart" corresponding to the respective running state of the composer status: string containing "up", "down", "restart", or "recreate" corresponding to the respective running state of the composer
""" """
try: try:
@@ -155,6 +155,14 @@ class Composer:
self.docker.compose.restart( self.docker.compose.restart(
services=[self.name] services=[self.name]
) )
elif status == "recreate":
self.docker.compose.up(
build=True,
detach=True,
force_recreate=True,
quiet=True,
remove_orphans=True
)
else: else:
logger.warn(f"Undefined status {status} - use up, down, or restart") logger.warn(f"Undefined status {status} - use up, down, or restart")
except DockerException as error: except DockerException as error:
@@ -241,7 +249,7 @@ class Service:
"""Sets the running status of the service """Sets the running status of the service
Args: Args:
status: string containing "up", "down", or "restart" corresponding to the respective running state of the service status: string containing "up", "down", "restart", or "recreate" corresponding to the respective running state of the service
""" """
try: try:
@@ -261,6 +269,15 @@ class Service:
self.parent.docker.compose.restart( self.parent.docker.compose.restart(
services=[self.name] services=[self.name]
) )
elif status == "recreate":
self.parent.docker.compose.up(
build=True,
detach=True,
force_recreate=True,
quiet=True,
services=[self.name],
remove_orphans=True
)
else: else:
logger.warn(f"Undefined status {status} - use up, down, or restart") logger.warn(f"Undefined status {status} - use up, down, or restart")
except DockerException as error: except DockerException as error: