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

Escript Troubles #35

Closed
andyl opened this issue Jan 14, 2022 · 8 comments
Closed

Escript Troubles #35

andyl opened this issue Jan 14, 2022 · 8 comments

Comments

@andyl
Copy link

andyl commented Jan 14, 2022

Using Muontrap in :dev and :test - all good.

When running in an Escript, I get an error ArgumentError unknown application :muontrap.

This comes from MuonTrap.Port#muontrap_path/0: Application.app_dir(:muontrap, ["priv", "muontrap"])

When I look in the _build directory I can see the /priv/muontop executable...

Does anyone have an idea of why this is failing in an Escript?

@andyl
Copy link
Author

andyl commented Jan 14, 2022

FYI I posted a simple Elixir repo which recreates the issue. See https://github.com/andyl/zing

@fhunleth
Copy link
Owner

I'm, unfortunately, not a user of Escripts so I don't know. I had the impression that libraries that supplied port binaries were incompatible with Escripts, but that doesn't sound like the error that you're running into. Hopefully someone lurking can provide a clue.

@fhunleth
Copy link
Owner

Just a thought, but does Application.app_dir/2 work for other libraries with Escripts? I'm not sure what muontrap would have done to break this that would be unique to it.

@axelson
Copy link
Contributor

axelson commented Jan 14, 2022

Yeah I think the issue is that Application.app_dir/2 doesn't work with escripts because there is no app directory for dependencies of an escript (although that may not be the 100% correct way of writing that). @andyl if it works for you maybe you could try using https://github.com/burrito-elixir/burrito instead of an script since I think deps will have an application directory then.

Although another alternative is to modify muontrap so it doesn't depend on Application.app_dir/2 and copy the binary manually and pass the path to the binary to muontrap. But that's rather invasive.

But for a partial example of what the calling code for that would look like you can take a look at how I handled it for erlexec:
https://github.com/axelson/ls_proxy/blob/6ae090620f4c1e9c95c403515cda3719f89862b2/ls_proxy/lib/erlexec_init.ex

A third alternative would be use erlexec (or its exexec wrapper) directly since it fulfills a similar goal to muontrap, unless what you needed was the cgroup support.

@fhunleth
Copy link
Owner

+1 to use Burrito instead of Escripts. That will work since you'll be making and running an OTP release.

That's an interesting workaround to Escripts for erlexec. If the only change to muontrap is to add an option supplying a port binary path and using it in preference to calling Application.app_dir/2 in muontrap, then that doesn't sound like a big change. (Given that erlexec works already, though, that does sound like possibly the easiest change.)

@andyl
Copy link
Author

andyl commented Jan 14, 2022

@axelson and @fhunleth - thanks for the guidance. I'll give it a try with Burrito and post here when I have some results.

@andyl
Copy link
Author

andyl commented Jan 14, 2022

From my Linux dev box I couldn't get Burrito to cross compile. I expect because Burrito is new and not yet fully tested.

Other than that Burrito runs MuonTrap as expected & looks like a good workaround!

The MuonTrap / Burrito demo is at https://github.com/andyl/mt_demo

MuonTrap is super nice! Thanks again for the tips.

@fhunleth
Copy link
Owner

Thanks for the update! Burrito is actively being worked on so, I expect it to get better. I really like the Burrito approach for this so I'm going to close this. Let me know if you have any other issues.

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

3 participants