just-containers / s6-overlay

s6 overlay for containers (includes execline, s6-linux-utils & a custom init)
Other
3.7k stars 209 forks source link

SIGHUP signal to child processes #347

Closed ikhader closed 2 years ago

ikhader commented 3 years ago

Hello Team, I am new here and trying to use s6-overlay-builder in my docker image.

My Docker file:

XXX COPY ./s6/services/ /etc/services.d/ XXX ENTRYPOINT ["/init"]

run script:

cat s6/services/job-handler/run

!/usr/bin/with-contenv sh

exec /job-handler

finish script:

cat s6/services/job-handler/finish

!/usr/bin/env sh

!/usr/bin/with-contenv sh

!/usr/bin/execlineb -P

s6-svscanctl -t /var/run/s6/services

process list

khader@s4:~/jh$ docker exec -it job-handler ps -eaf PID USER TIME COMMAND 1 root 0:00 s6-svscan -t0 /var/run/s6/services 32 root 0:00 s6-supervise s6-fdholderd 171 root 0:00 s6-supervise job-handler 175 root 0:06 /job-handler 220 root 0:00 ps -eaf

Send SIGHUP

docker kill --signal=SIGHUP job-handler

I don't see SIGHUP in my job-handler module. Any help on how to do this?

skarnet commented 2 years ago

v3.0.0.0 is out, I'm answering your question with paths and commands that are valid for 3.0.0.0.

docker kill sends the signal to pid 1 in the container, in this case s6-svscan, which has reacted to it by updating its supervision tree, i.e. doing nothing since the tree hasn't changed since the last scan. If what you want is to send a SIGHUP to your /job-handler process, you will need to run docker exec job-handler s6-svc -h /run/service/job-handler.

Note that rather than running /job-handler as a supervised service, we recommend running it as your CMD if the container is supposed to exit when /job-handler exits. In this case, in order to send it a SIGHUP, you'd need to find its pid in the container, then run docker exec job-handler kill "$pid".

Closing this issue; please reopen if it's not working for you.