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

zombie_killer not executing correctly #110

Closed
grantwest opened this issue Nov 6, 2019 · 9 comments · Fixed by #112 · May be fixed by #111
Closed

zombie_killer not executing correctly #110

grantwest opened this issue Nov 6, 2019 · 9 comments · Fixed by #112 · May be fixed by #111

Comments

@grantwest
Copy link
Contributor

grantwest commented Nov 6, 2019

I am having a problem with zombie_killer not actually running the tests. I have a standard Phoenix project and I am running in the elixir:1.9.2 docker container, which is debian based.

I put a set -x at the beginning of my zombie_killer script and this is what I end up with:

Running tests...
+ pid1=9542
+ exec
+ exec sh -c MIX_ENV=test mix do run -e 'Application.put_env(:elixir, :ansi_enabled, true);', test

It never makes it to the rest of the script. But zombie_killer does finish running because I can see that is is no longer running ps aux. Also, the thing reruns if I change a file. I can also prove that the tests are not actually running by making one of the tests create a file and seeing that the file is not created.

When I just run the mix command it works fine:

$ MIX_ENV=test mix do run -e 'Application.put_env(:elixir, :ansi_enabled, true);', test
...........

Finished in 0.1 seconds
11 tests, 0 failures

Randomized with seed 146993

The absolute simplest way that I have found to solve this is to just change the first line of zombie_killer to #!/bin/bash, but I am guessing not everyone is going to want bash.

I see that zombie_killer was recently added, maybe @rjdellecese can weigh in?

@lpil lpil added the Kind: Bug label Nov 6, 2019
@rjdellecese
Copy link
Contributor

@grantwest I think you're probably not seeing any more output beyond that point because of

# Silence warnings from here on
exec >/dev/null 2>&1

If you uncomment that line and run it with set -x, what do you see?

I think that different versions of kill might take different flags sometimes, e.g. kill -KILL vs. kill -SIGKILL, so it could be that we need to use the signal number (kill -9) instead in order to be more OS-/distro-agnostic. What happens if you replace the two kill -KILLs with kill -9?

@grantwest
Copy link
Contributor Author

Commenting out the exec >/dev/null 2>&1 yields this:

Running tests...
+ pid1=23943
+ pid2=23944
+  shwait MIX_ENV=test mix do run -e 'Application.put_env(:elixir, :ansi_enabled, true);', test
 23943
+ read
/src/_build/dev/lib/mix_test_watch/priv/zombie_killer: 14: read: arg count
+ kill -KILL 23943
+ ret=137
+ kill -KILL 23944
+ exit 137

Looks like the sh version of read doesn't like to be called without args. I can change it to be read UNUSED; and then I get this:

Running tests...
+ pid1=26902
+ exec sh -c MIX_ENV=test mix do run -e 'Application.put_env(:elixir, :ansi_enabled, true);', test
+ pid2=26903
+ wait 26902
+ read UNUSED
+ kill -KILL 26902
+ ret=137
+ kill -KILL 26903
+ exit 137

The tests still aren't running though. I think it has something to do with the quoting of the args to the exec sh -c command.

@vheathen
Copy link

vheathen commented Nov 8, 2019

Doesn't work for me either. It works if I change the zombie killer script shell to bash.

@lpil
Copy link
Owner

lpil commented Nov 9, 2019

Why do we not use the script recommended by the standard library? https://hexdocs.pm/elixir/Port.html#module-zombie-operating-system-processes

@rjdellecese
Copy link
Contributor

rjdellecese commented Nov 10, 2019

I initially tried adding that script in #106, but it didn't work for me. The version that I ended up adding here is the one that's in the Port module documentation in the master Elixir branch (I'm not sure why it's not in the most recent Elixir release), which was the culmination of this issue (elixir-lang/elixir#9171).

Since this is just a copy of the script that exists in the Elixir lang repo, perhaps it would make more sense to open an issue and ask for help there? If we can make it more portable, we'd probably want that change to be made in the Port documentation also, either way?

@lpil
Copy link
Owner

lpil commented Nov 10, 2019

Perhaps a wider discussion would be beneficial. If this script does work for everyone I may revert to not using it until it is ready.

@rmoorman
Copy link

Over here, (Ubuntu 18.04, erlang solutions erlang and elixir) creating a fresh project with mix new and with version 1.0.1 of this package added to deps does not show test output at all

$ mix test.watch

Running tests...

Running tests...

Running tests...

Running tests...
^C

(here i changed the generated test a couple of times until I gave up)

Switching back to version 0.9 however yields test output just as it used to be.

Furthermore, I can confirm that when using version 1.0.1, I can get it to work when I manually edit the zombie_killer script to use bash instead of sh (as @grantwest and @vheathen also pointed out)

@rjdellecese
Copy link
Contributor

That makes sense @lpil. Sorry for the issues, everyone!

@grantwest, would you like to open an issue in elixir-lang/elixir to follow up on this? I'd also be happy to!

@lpil
Copy link
Owner

lpil commented Nov 13, 2019

Thanks for the excellent feedback everyone!

What do we think about using bash instead of sh? Seeing as this is a dev tool I think that would be reasonable.

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

Successfully merging a pull request may close this issue.

5 participants