Comments (8)
The design of erlexec
was implying that if the beam
is killed, then the exec-port
process would detect the pipe closing, and would kill all of its jobs. The last time I tested this on Linux a few years back it worked without issues. If it doesn't work with docker for some reason you'd need to troubleshoot (setting the debug and verbose modes, and trying to see where the issue is). I don't think it's related to the custom kill command.
from erlexec.
The design of
erlexec
was implying that if thebeam
is killed, then theexec-port
process would detect the pipe closing, and would kill all of its jobs.
This definitely works. I relied on it in the past, and I also double checked that it still works today.
I don't think it's related to the custom kill command.
My impression is that custom kill command is not executed if beam is killed. Here's a simple demo in Elixir:
{:ok, pid, _ospid} = :exec.run(
"""
function cleanup {
echo "got exit signal" >> debug.txt
}
trap cleanup 0
sleep infinity
""",
kill: ~s/echo "custom kill command" >> debug.txt/
)
If I invoke this in iex
shell, and then invoke :exec.stop(pid)
, debug.txt will contain custom kill command
. However, if I start the program and kill the shell by hitting ctrl+c twice, then debug.txt will contain only got exit signal
(make sure to remove the file before restarting the experiment).
This indicates that erlexec
ignores the custom kill command when cleaning up after beam is killed, and instead always sends an exit signal.
from erlexec.
A custom kill command only gets executed when a child process is not getting terminated by SIGTERM. Only in that case exec-port
will execute the custom kill command. So in your example above the log contains got exit signal
, which is indicative that the child process got killed and there was no need to execute the custom kill command.
from erlexec.
I see. My question is then how can I ensure that custom kill command is immediately executed in the following situations:
- When the beam stops (normally or abnormally)
- When the linked process crashes
- When manually stopping the OS process with
stop
(from what I can tell this already works today)
I tried playing with kill_timeout
, but that doesn't seem to do the trick. I basically need some way of instructing erlexec to immediately move on to the custom command without even trying with SIGTERM. Or perhaps, alternatively, I'd like to provide a custom terminate (not kill) command which would be used instead of SIGTERM. Is any of that possible today?
from erlexec.
In the current implementation the kill command is the fallback for the failed SIGTERM. It seems to me that you can solve your problem simply by writing a wrapper script for your child task, which traps SIGTERM, and executes the custom command you need.
You are also welcome to submit a patch that adds an option to force the kill command without SIGTERM.
from erlexec.
It seems to me that you can solve your problem simply by writing a wrapper script for your child task, which traps SIGTERM, and executes the custom command you need.
Yeah this is the approach I'm currently using, although it feels slightly hacky.
I'll see if I can submit a patch, but I need to dust off my C++ first, so I can't commit to any deadline :-)
from erlexec.
I believe that the latest commit fixed this issue.
from erlexec.
Cool! I forgot about this issue, b/c I went down the different path and rolled my own small port command wrapper. So regardless of whether this is solved or not, feel free to close this issue, b/c I personally won't find the time to work on it.
from erlexec.
Related Issues (20)
- Application exec_app killed HOT 7
- Disable erl_interface for Erlang 23 HOT 1
- :env option in 1.18.8 HOT 2
- Establishing/Supervising Communications With a Long-Running, Data Streaming Python Process HOT 3
- New release? Resolve port hanging HOT 2
- Exit codes appear to be x256 too large HOT 1
- erlexec on linux slows down when nofile limit is a large value HOT 2
- Mac OS error: use of undeclared identifier 'pipe2' HOT 2
- Could not compile dependency :erlexec HOT 15
- I am running into issues with elixir release HOT 3
- When native stdin process buffer is full, erlexec does not retry HOT 11
- PTY dynamic option test failing HOT 6
- Does 2.0.0 contain a breaking change? HOT 1
- Compile failure on OSX M1 mac HOT 4
- Passing command arguments as list HOT 1
- USE_POLL is not set HOT 1
- Failed build on FreeBSD HOT 9
- Compile fails on arm HOT 4
- Any command terminates with exit status 132 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from erlexec.