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.