Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Correctly handle signals #77

Closed
wants to merge 3 commits into from
Closed

Conversation

lukechilds
Copy link

Currently caxa does not pass signals through to the child process, that results in some weird behaviour where you think you're killing the process but you're actually only killing the stub process and the node process continues to run.

You can recreate this behaviour by building the examples/web-application project, running the web-application binary in the background, and then killing it:

$ web-application &
Server started at http://localhost:4000

$ ps -Af | grep web-application
root     11586     1 30 10:53 pts/0    00:00:00 ./web-application
root     11593 11586  9 10:53 pts/0    00:00:00 /tmp/caxa/applications/web-application/ukorlhplcx/0/node_modules/.bin/node /tmp/caxa/applications/web-application/ukorlhplcx/0/build/index.mjs

$ kill 11586

$ ps -Af | grep web-application
root     11593     1  9 10:53 pts/0    00:00:00 /tmp/caxa/applications/web-application/ukorlhplcx/0/node_modules/.bin/node /tmp/caxa/applications/web-application/ukorlhplcx/0/build/index.mjs

You can see only the stub is killed, the node process is left running because the SIGTERM signal is not forwarded on to the child process.

With the changes in this PR applied the stub now forwards all signals on to the child process so killing the stub process behaves how you would expect:

$ web-application &
Server started at http://localhost:4000

$ ps -Af | grep web-application
root     11586     1 30 10:53 pts/0    00:00:00 ./web-application
root     11593 11586  9 10:53 pts/0    00:00:00 /tmp/caxa/applications/web-application/ukorlhplcx/0/node_modules/.bin/node /tmp/caxa/applications/web-application/ukorlhplcx/0/build/index.mjs

$ kill 11586

$ ps -Af | grep web-application

@lukechilds
Copy link
Author

lukechilds commented Jun 28, 2023

Hey @leafac I'm sure you're busy buy any chance you'd be able to take a quick look at this? It's quite a simple change and the current behaviour in caxa is causing issues for us. Thanks!

@papb
Copy link

papb commented Jun 29, 2023

I'm not @leafac, but I was wondering, is it feasible to add a test to verify this? From experience, handling signals can be weird. Also, from your OP it seems you have the issue in Linux, do you know if it happens in the other platforms?

@leafac
Copy link
Owner

leafac commented Nov 21, 2023

Hi @lukechilds & @papb,

First of all, thank you very much for your contribution! I appreciate the time you took into using caxa, identifying the issue with signals (which is very tricky to investigate!), and coming up with a solution.

I’ve been thinking about the broad strategy employed by caxa and concluded that there is a better way to solve the problem. It doesn’t include a stub, so it subsumes this pull request.

It’s a different enough approach that I think it deserves a new name, and it’s part of a bigger toolset that I’m building, which I call Radically Straightforward · Package.

I’m deprecating caxa and archiving this repository. I invite you to continue the conversation in Radically Straightforward’s issues.

Best.

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

Successfully merging this pull request may close these issues.

3 participants