Skip to content

Communication over Erlang port does not work in release version #6166

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

Closed
DerKastellan opened this issue May 29, 2017 · 5 comments
Closed

Communication over Erlang port does not work in release version #6166

DerKastellan opened this issue May 29, 2017 · 5 comments

Comments

@DerKastellan
Copy link
Contributor

DerKastellan commented May 29, 2017

Precheck

  • Do not use the issues tracker for help or support (try Elixir Forum, Stack Overflow, IRC, etc.)
  • For proposing a new feature, please start a discussion on the Elixir Core mailing list
  • For bugs, do a quick search and make sure the bug has not yet been reported
  • Finally, be nice and have fun!

Done.

Environment

  • Elixir & Erlang versions (elixir --version):
    elixir --version
    Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:48:48] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.3.4

cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)

Current behavior

When I use my communication through an Erlang port in a escript or with mix run, it works. When I do a mix release with distillery (1.4), in the resulting application the communication over the pipe doesn't work anymore for no apparent reason. It simply hangs as soon when it writes to the pipe. The port application itself never receives anything over the pipe but starts up.

I wrote a sample application to replicate my problem: https://github.com/DerKastellan/release-weirdness

Expected behavior

Pipe communication to Erlang port should work whether in dev mode with mix or in released application.

I would appreciate any help with this. I'm at a loss why behavior changes when using distillery...

@josevalim
Copy link
Member

@DerKastellan if you see the output that you have added of File.cwd you will notice that the current working directory is different. The release runs inside the release directory. Any file that you need in production needs to be in the priv directory. So you should move the file to "priv/test.esh" and then locate it using Application.app_dir(:name_of_your_app, "priv/test.esh").

Finally, if you are not sure if something is a bug and you need help, prefer to use the Elixir Forum or Stack Overflow. We are very few maintainers and unfortunately we cannot help everyone in the community. If nobody can identify the root cause, then it is fine to open up an issue. If you have done that already, then no sweat!

@DerKastellan
Copy link
Contributor Author

DerKastellan commented May 29, 2017 via email

@josevalim
Copy link
Member

Awesome that you tried to get help before, thank you!

It worked correctly in a release but I cannot get it to work anymore. :( I will reopen until I can provide the full instructions.

@josevalim josevalim reopened this May 29, 2017
@josevalim
Copy link
Member

josevalim commented May 29, 2017

Ok, apparently it didn't work and I tested the wrong thing when I thought it did. So the issue is that, when you run the release, it changes your PATH and it is picking the escript executable inside the release, at _build/dev/rel/sample/erts-x.y/bin/escript. If you remove that escript file, then it will work again, as it will pick the escript in your machine.

Now, the release escript is the same as you have in your machine, but I assume it does not work because your release is configured to run differently than the erlang installed in your machine.

I would advise opening up an issue in distillery for further investigation as it is not an Elixir issue per se. It may be an Erlang issue though - although it is debatable if escripts are supposed to be part of the release.

@DerKastellan
Copy link
Contributor Author

Thank you for your time, José!

I will heed your advice and direct my issue elsewhere. I do appreciate the help.

(The script is just a placeholder for host testing, delivering predefined responses, I also deliver a C application for production use on target machine with different functionality that uses a legacy API.)

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

No branches or pull requests

2 participants