mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-16 05:28:42 +02:00
Extract run_container()
Signed-off-by: Felix Rubio <felix@kngnt.org> Modified-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
626e278794
commit
002c2e400b
@ -2502,6 +2502,15 @@ def get_excluded(compose, args):
|
|||||||
return excluded
|
return excluded
|
||||||
|
|
||||||
|
|
||||||
|
async def run_container(
|
||||||
|
compose: PodmanCompose, name: str, command: tuple, log_formatter: str = None
|
||||||
|
):
|
||||||
|
"""runs a container after waiting for its dependencies to be fulfilled"""
|
||||||
|
|
||||||
|
log.debug("Starting task for container %s", name)
|
||||||
|
return await compose.podman.run(*command, log_formatter=log_formatter)
|
||||||
|
|
||||||
|
|
||||||
@cmd_run(podman_compose, "up", "Create and start the entire stack or some of its services")
|
@cmd_run(podman_compose, "up", "Create and start the entire stack or some of its services")
|
||||||
async def compose_up(compose: PodmanCompose, args):
|
async def compose_up(compose: PodmanCompose, args):
|
||||||
excluded = get_excluded(compose, args)
|
excluded = get_excluded(compose, args)
|
||||||
@ -2546,7 +2555,7 @@ async def compose_up(compose: PodmanCompose, args):
|
|||||||
podman_args = await container_to_args(compose, cnt, detached=args.detach)
|
podman_args = await container_to_args(compose, cnt, detached=args.detach)
|
||||||
subproc = await compose.podman.run([], podman_command, podman_args)
|
subproc = await compose.podman.run([], podman_command, podman_args)
|
||||||
if podman_command == "run" and subproc is not None:
|
if podman_command == "run" and subproc is not None:
|
||||||
await compose.podman.run([], "start", [cnt["name"]])
|
await run_container(compose, cnt["name"], ([], "start", [cnt["name"]]))
|
||||||
if args.no_start or args.detach or args.dry_run:
|
if args.no_start or args.detach or args.dry_run:
|
||||||
return
|
return
|
||||||
# TODO: handle already existing
|
# TODO: handle already existing
|
||||||
@ -2578,7 +2587,12 @@ async def compose_up(compose: PodmanCompose, args):
|
|||||||
|
|
||||||
tasks.add(
|
tasks.add(
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
compose.podman.run([], "start", ["-a", cnt["name"]], log_formatter=log_formatter),
|
run_container(
|
||||||
|
compose,
|
||||||
|
cnt["name"],
|
||||||
|
([], "start", ["-a", cnt["name"]]),
|
||||||
|
log_formatter=log_formatter,
|
||||||
|
),
|
||||||
name=cnt["_service"],
|
name=cnt["_service"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user