diff options
author | Linus Nordberg <linus@sunet.se> | 2020-01-06 16:32:21 +0100 |
---|---|---|
committer | Linus Nordberg <linus@sunet.se> | 2020-01-07 23:09:09 +0100 |
commit | ae6fc8623e35eae56aad02d9a1f922199a59ad36 (patch) | |
tree | 9518e11114d1f004ea037ab5a6d2af6b899d59e9 /p11p-daemon/src/p11p_remote.erl | |
parent | 00d3b28a452ff821ed689b22d77ad6719f6addb9 (diff) |
Set up environment for remotes according to configuration
Diffstat (limited to 'p11p-daemon/src/p11p_remote.erl')
-rw-r--r-- | p11p-daemon/src/p11p_remote.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/p11p-daemon/src/p11p_remote.erl b/p11p-daemon/src/p11p_remote.erl index 1247f12..6a050e6 100644 --- a/p11p-daemon/src/p11p_remote.erl +++ b/p11p-daemon/src/p11p_remote.erl @@ -16,7 +16,7 @@ -behaviour(gen_server). %% API. --export([start_link/3]). +-export([start_link/4]). -export([request/2, add_to_outbuf/2, stop/2]). -include("p11p_rpc.hrl"). @@ -36,10 +36,10 @@ }). %% API. --spec start_link(atom(), string(), string()) -> {ok, pid()} | {error, term()}. -start_link(ServName, TokName, ModPath) -> +-spec start_link(atom(), string(), string(), list()) -> {ok, pid()} | {error, term()}. +start_link(ServName, TokName, ModPath, ModEnv) -> lager:info("~p: p11p_remote starting for ~s", [ServName, ModPath]), - gen_server:start_link({local, ServName}, ?MODULE, [TokName, ModPath], []). + gen_server:start_link({local, ServName}, ?MODULE, [TokName, ModPath, ModEnv], []). -spec request(pid(), p11rpc_msg()) -> ok. request(Remote, Request) -> @@ -58,11 +58,16 @@ stop(Pid, Reason) -> gen_server:cast(Pid, {stop, Reason}). %% Genserver callbacks. -init([TokName, ModPath]) -> +init([TokName, ModPath, ModEnv]) -> RemoteBinPath = p11p_config:remotebin_path(), Port = open_port({spawn_executable, RemoteBinPath}, - [stream, exit_status, {args, [ModPath, "-v"]}]), + [stream, + exit_status, + {env, ModEnv}, + {args, [ModPath, "-v"]} % FIXME: Remove -v + ]), lager:debug("~p: ~s: new remote port: ~p", [self(), RemoteBinPath, Port]), + lager:debug("~p: ~s: module: ~s, env: ~p", [self(), RemoteBinPath, ModPath, ModEnv]), {ok, #state{port = Port, token = TokName}}. handle_call({add_to_outbuf, Data}, _From, State) -> |