Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue printing log output after Ctrl-C has been pressed #592

Closed
bfirsh opened this issue Oct 28, 2014 · 10 comments
Closed

Continue printing log output after Ctrl-C has been pressed #592

bfirsh opened this issue Oct 28, 2014 · 10 comments

Comments

@bfirsh
Copy link

bfirsh commented Oct 28, 2014

When I run fig up and hit Ctrl-C, the log output stops immediately. It'd be useful to keep on printing log output until the process stops.

@sylvinus
Copy link

+1

1 similar comment
@parshap
Copy link

parshap commented Feb 20, 2015

👍

@matikucharski
Copy link

Any update on this?

@Dobiasd
Copy link

Dobiasd commented Apr 26, 2019

Just ran into the same problem.

Here is a minimal example to reproduce the issue:


Here is a service (python in that example) that prints something on SIGINT/SIGTERM.

printer.py:

import signal
import sys
import threading

def runner(stop_event):
    while not stop_event.wait(1):
        print('Hi.', flush=True)

stop_event = threading.Event()

def signal_handler(*_):
    stop_event.set()
    print('Bye.', flush=True)
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

runner_thread = threading.Thread(target=runner, args=(stop_event,))
runner_thread.start()
runner_thread.join()

When running normally in the terminal and pressing CTRL+C, it works fine, i.e., the Bye. message is printed:

$ python3 printer.py 
Hi.
Hi.
^CBye.

However when running with Docker compose and CTRL+C-ing it, Bye. is never shown.

Dockerfile:

FROM python:3.7
ADD printer.py .
CMD [ "python", "printer.py" ]

docker-compose.yml:

version: '2.4'

services:
  printer:
    build:
      context: .
      dockerfile: Dockerfile

Terminal interaction:

$ docker-compose up
Creating network "compose_print_term_default" with the default driver
Creating compose_print_term_printer_1 ... done
Attaching to compose_print_term_printer_1
printer_1  | Hi.
printer_1  | Hi.
^CGracefully stopping... (press Ctrl+C again to force)
Stopping compose_print_term_printer_1 ... done

It would be really great if it could continue to print the log output instead.

@stale
Copy link

stale bot commented Oct 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 23, 2019
@stale
Copy link

stale bot commented Oct 30, 2019

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Oct 30, 2019
@Dobiasd
Copy link

Dobiasd commented Oct 30, 2019

This issue has been automatically closed because it had not recent activity during the stale period.

Oh, that's sad. For me, it's still an issue.

@Shawak
Copy link

Shawak commented Sep 15, 2020

Also having this problem.

@tomlagier
Copy link

Still an issue for me as well. Makes it very difficult to determine whether cleanup behavior is happening correctly or not.

@jkgeyti
Copy link

jkgeyti commented May 17, 2021

This seems like a genuine omission, and is still tracked in #2227 . Can it be reopened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants