mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-11 02:59:36 +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()
|
||||
|
||||
async def handle_sigint():
|
||||
log.info("Caught SIGINT, shutting down...")
|
||||
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
|
||||
await compose.commands["down"](compose, down_args)
|
||||
for task in tasks:
|
||||
task.cancel()
|
||||
log.info("Caught SIGINT or Ctrl+C, shutting down...")
|
||||
try:
|
||||
log.info("Shutting down gracefully, please wait...")
|
||||
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False))
|
||||
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':
|
||||
loop = asyncio.get_event_loop()
|
||||
|
Loading…
Reference in New Issue
Block a user