upcmd / up

UP - Ultimate Provisioner CLI
https://upcmd.netlify.app/
MIT License
50 stars 4 forks source link

Interrupt shell process gracefully when up process interrupted #22

Closed llCorvinSll closed 2 years ago

llCorvinSll commented 3 years ago

Hi. I want to setup up for development environment and add commands to it. For example start docker-compose up with something like this

tasks:
  - name: dev_up
    task:
    - func: shell
      do:
      - cd {{.docker_dir}} && docker-compose up

but when i press ctr-c in shell up process stops immediately and not clean containers like in normal shell. I thin this is because docker-compose process not receive ctrl-c command

stephencheng commented 3 years ago

can you try this one: https://github.com/upcmd/up/blob/master/tests/functests/p0205.yml ?

Can you send me a reproducible docker compose yml file for a test?

I would assume your main process is not a shell session could handle the native ctrl-c

llCorvinSll commented 3 years ago

This works, but docker-compose non interactive and not open another shell. Like other watchers and dev soft. workaround with compose is like this

      do:
      - /bin/bash -ci "cd {{.docker_dir}} && docker-compose up"

P.S: p0205.yml use docker image that require auth for docker

stephencheng commented 3 years ago

This works, but docker-compose non interactive and not open another shell. Like other watchers and dev soft. workaround with compose is like this

      do:
      - /bin/bash -ci "cd {{.docker_dir}} && docker-compose up"

Yes, you are right. The ctrl-c will interrupt the upcmd task execution if it is running or hanging there, since the command "docker-compose up" is not an interactive session, the ctrl-c will not be passed on to docker-compose at all

Your workaround is actually the solution for this

P.S: p0205.yml use docker image that requires auth for docker

Thanks, you can use a tiny image for your own test instead, I will fix this