Re: Supervisor and configuration update — how to do it?

Ameretat Reith ameretat.reith@REDACTED
Wed May 20 23:24:11 CEST 2020

I used to separate worker parameters to dynamic or static; static parameters
would be set by supervisor but dynamic ones would be inducted from application
env on worker initialization _or_ at runtime. So, each worker needing dynamic
parameters, would have a `do_load_option` function invoking
`application:get_env`  for each interesting dynamic parameter, and it would be
called on worker initialization, e.g. in `init/1` for gen_servers then
populate state. And like your approach, there was a `handle_call` to invoke
`do_load_options` and reset state. This message would be sent on to workers
found by `supervisor:which_children`.

I had scripts (Juju hooks and then a homebuilt deployment system hook) that
could set application env in sys.config on configuration changes. Then, that
hook would call (rpcterms) a rpc on release to reload `sys.config`. This
`reload_sys_config` calls `application_controller:change_application_data` to
update envs and then procedures to call `do_load_options` on workers.

More information about the erlang-questions mailing list