-
Notifications
You must be signed in to change notification settings - Fork 155
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
Support running as PID 1 #140
Comments
That sounds reasonable |
Actually I can't reproduce this. Sending SIGTERM to watchexec kills it (and the child). Can you provide more detail as to how and what you're running? |
Right, forgot that detail. It only seems to happen when running it as the main process in docker (PID 1) which has some special behaviour around signals. To reproduce Dockerfile
test.sh
Build and run docker
With the container running Remove the watchexec invocation and run the bare |
(Sorry for taking so long, I am looking at this and haven't forgotten.) |
Tried fixing this for a few days but ran into issues and it's delaying release, so I'm shelving this for now. Not happy about it, but I have to get other stuff out of the door before coming back to it. |
@passcod I'm still running into this issue, did you ever get a chance to do more debugging? Is there anything I can do to help with the debugging? |
Haven't done anything more since. Workaround is obviously to not run as PID 1 (not hard, just wrap it in a shell), but I haven't looked deeper at how the way signals work for PID 1 affects its handling in watchexec. It's been a year and I've forgotten things (also I'm busy, november is basically the worst time as I do nanowrimo); if you want to help better repro it from scratch and look at the handling code in signal.rs. |
ok thanks, I will use an init process in the mean time and I'll try to do some debugging next week |
Dropping a note for future visitors that for the specific case of Docker, running with the |
If you're using watchexec as a sidecar in a kubernetes pod, a workaround for that (but only if your scripts can handle ungraceful stops), a workaround is to add the following to your watchexec container Dockerfile: STOPSIGNAL SIGKILL |
@Marwes pid 1 ignores most signaling to not "accidentially shutting down the system", because child processes may use pid 1 as process group to signal the other children. Thus |
This will be in 1.21.1 |
When running watchexec (really, cargo-watch) in a docker container I would like that the watchexec process shutsdown when I request that the docker container shutsdown.
Currently SIGTERM is handled and sent to the child process which shutsdown my program as expected, but after that nothing happens. What I would like is that
watchexec
, after seeing the child process shutdown also shutsdown itself.The text was updated successfully, but these errors were encountered: