autodidaddict
Using environment variables with ports
In this previous post here, the poster asks the same question I have. I cannot seem to get the syntax correct in order to launch a Port with environment variables.
The solution shows how to do it using System.cmd, but I need a port because I need to manage the pid and this executable will be running for a long time. The erlang syntax is also in the original post, but I need to know how to do this in Elixir.
The Elixir code that I have that does not work (gives me “bad argument”) is as follows:
host_info = HostCore.Host.generate_hostinfo_for(public_key)
port = Port.open({:spawn, "#{path}"}, [:binary, {:env, [{'WASMCLOUD_HOST_DATA', host_info}]}] )
Where host_info is just a Jason encoded string.
Marked As Solved
LostKobrakai
Based on the typespecs in the erlang docs this needs to be a charlist not a binary.
Also Liked
LostKobrakai
Erlang functions often take what is called proplists, which are lists of either atoms, or {atom, value} tuples like elixir keyword lists have.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








