mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-18 14:39:00 +02:00
add try-except block to handle error in case of shutdown error
Signed-off-by: Mohammad Kazemi <mokazemi@disroot.org>
This commit is contained in:
parent
3973c476c4
commit
b748c2666c
@ -2780,11 +2780,16 @@ async def compose_up(compose: PodmanCompose, args):
|
|||||||
tasks = set()
|
tasks = set()
|
||||||
|
|
||||||
async def handle_sigint():
|
async def handle_sigint():
|
||||||
log.info("Caught SIGINT, shutting down...")
|
log.info("Caught SIGINT or Ctrl+C, shutting down...")
|
||||||
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
|
try:
|
||||||
await compose.commands["down"](compose, down_args)
|
log.info("Shutting down gracefully, please wait...")
|
||||||
for task in tasks:
|
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
|
||||||
task.cancel()
|
await compose.commands["down"](compose, down_args)
|
||||||
|
except Exception as e:
|
||||||
|
log.error(f"Error during shutdown: {e}")
|
||||||
|
finally:
|
||||||
|
for task in tasks:
|
||||||
|
task.cancel()
|
||||||
|
|
||||||
if sys.platform != 'win32':
|
if sys.platform != 'win32':
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
Loading…
Reference in New Issue
Block a user