Open cake-monotone opened 11 months ago
How about this flows?
What do you think of this idea?
+1 Same here - the described problem prevents Docker from achieving a 'graceful exit'. Any solutions?
I'm also experiencing this issue with Docker. My work around is to start the container with -d
and then I have a stop task which I run at the beginning of the stop task to try and kill the container. It's fine, but it would be better if signals propagated.
Here's what I do for anyone who is dealing with this for Docker:
# https://taskfile.dev
version: "3"
vars:
IMAGE_NAME: my-app
IMAGE_TAG: latest
IMAGE: "{{.IMAGE_NAME}}:{{.IMAGE_TAG}}"
tasks:
default:
desc: Shows this help message
cmds:
- task --list-all
build:
desc: Build the app
cmds:
- docker build . -t {{.IMAGE}}
start:
desc: Start the app
deps:
- build
cmds:
- cmd: task stop
ignore_error: true
- docker run -d --rm -p 8080:8080 --name my-app {{.IMAGE}}
- cmd: docker logs --follow my-app
ignore_error: true
stop:
desc: Stop the app
cmds:
- docker stop my-app
The signal handling is consuming these signals. You could try an experiment and comment out this line and see if it works like you expect.
Or, an alternative might be to send a different signal and see if that gets propagated. For instance, HUP as follows:
docker kill --signal=SIGHUP task_container
and then you need a program that catches that ... basic idea here https://gobyexample.com/signals.
The actual process that Task runs seems to come into existence here and AFAICS nothing would prevent a signal propagating through (other than they are currently consumed by Task implementation).
Script:
signal-test.sh
Task Configuration:
Taskfile.yml
Given the process structure:
When executing kill -INT 2, the following output is observed:
It is critical to note that the SIGINT signal fails to reach the subprocess. This issue is particularly problematic when using Taskfile within a Docker container. Both
docker stop
and CTRL-C interruption duringdocker run
attempt to send SIGINT or SIGTERM to the Taskfile process directly. The described problem prevents Docker from achieving a 'graceful exit'.