Skip to content
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

Wachers process that I use in dev environment aren't killed when I kill my app by Ctrl-C #2215

Closed
asiniy opened this issue Mar 24, 2017 · 3 comments

Comments

@asiniy
Copy link

asiniy commented Mar 24, 2017

Environment

  • Elixir version (elixir -v): 1.3.4
  • Phoenix version (mix deps): 1.2.0
  • NodeJS version (node -v): 6.6.0
  • NPM version (npm -v): 3.10.3
  • Operating system: ubuntu 16.04 32 bit

Expected behavior

I have a watcher in my dev environment which is a simple webpack builder with ability to --watch-stdin.

watchers = [
  {"node", ["node_modules/webpack/bin/webpack.js", "--watch-stdin", "--progress", "--colors"]},
]

The problem is that when I stop phoenix server via Ctrl-C in my terminal this webpack process is still running. It's sad, especially if I know that every running instance decreases available RAM amount by 200MB.

So, 5 restarts (if I edit something in my lib or config) devours 1GB of memory! Is it a bug or feature? I thought that watcher processes should be killed too when I stop my phoenix server...

@josevalim
Copy link
Member

It is not the responsibility of the Phoenix server to do so. Please make sure the webpack IS listening to stdin and shutting down when the stdin is closed. More information found here in the zomie process section: hexdocs.pm/elixir/Port.html

@Kjir
Copy link

Kjir commented Nov 4, 2017

To be honest I question this a little bit: if all processes watched stdin at all times, no process would be executable in the background with the shell &. And long running processes — like the dev server, or emacs for that matter — that don't process information from the standard input are perfect candidates to be executed as a background job.

On the other hand, I can see why we might want processes to do that in the context of the Erlang VM. But this model doesn't really fit the aforementioned tools.

Also, to me the proposed workaround doesn't really work: it will still block on the long running process and it will not get the PID anyway. A better script would be:

#!/bin/sh
"$@" &
while read line ; do
  :
done
kill -KILL %%

This has the downside that if the background job exits, the script will still run...

@matthewadowns
Copy link

I am able to use --watch-options-stdin, which kills the node processes when the server exits.

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

No branches or pull requests

4 participants