poolboy
poolboy copied to clipboard
Remote Workers and Worker-Supervisor
Remote Workers
I needed to create a pool of processes similar to the rpc
module implementation in Erlang/OTP. - rpc
(or rex
) is a single process, I needed a pool of them. - This led me to extend poolboy, so that (local) workers could be started by a supervisor on a remote node.
For this to work these are the necessary steps:
- Find the
Pid
of the Worker-Supervisor, even if remote, seefind_pid/1
- Start the workers via their Supervisor, even if Supervisor is remote, see
new_worker/2
- Monitor Worker-Supervisors, that were passed in and
stop
if they goDOWN
- Monitor Remote
node
if Worker-Supervisor is remote andstop
onnodedown
- Stop Worker-Supervisor using
gen_server:stop/1
, so that it works remotely too. See:stop_supervisor/2