1
0
angie-conv-image/angie/conf.dist/core-worker-env.conf.j2
Konstantin Demin a69d6c2920
refactor environment handling
also:
- drop "njs" directories (not actually used nor useful)
- rework jinja filters: more functions, shorter names, etc.
2024-07-23 00:03:46 +03:00

28 lines
989 B
Django/Jinja

{#- prologue -#}
{#- NB: "TZ" is always provided by Angie itself -#}
{%- set s_vars = ['MALLOC_ARENA_MAX', 'GLIBC_TUNABLES', 'MALLOC_CONF'] -%}
{%- set c_env = ( j2cfg.core_worker_env or [] ) | any_to_env_dict -%}
{%- set c_vars = c_env | dict_keys -%}
{%- set c_vars_preserve = c_env | dict_empty_keys -%}
{%- set c_vars_override = c_env | dict_non_empty_keys -%}
{%- set vars_preserve = ( c_vars_preserve + ( s_vars | list_diff(c_vars) )) | sort -%}
{#- main part -#}
{%- if vars_preserve %}
## preserve
{%- for k in vars_preserve %}
env {{ k }};
{%- endfor %}
{% endif %}
{%- if c_vars_override %}
## WARNING!
## explicit environment variables are NOT implemented
## reason: envs are supported only for http_perl but not for http_js/stream_js
## solution: provide environment variables explicitly
## and then list them in "core_worker_env" key in config
{%- for k in c_vars_override %}
{%- set v = c_env[k] -%}
# env {{ k }}={{ v.__repr__() }};
{%- endfor %}
{% endif %}