diff --git a/angie/conf.dist/core-preserve-env.conf.j2 b/angie/conf.dist/core-preserve-env.conf.j2 index 2f31b0f..f4ff5e5 100644 --- a/angie/conf.dist/core-preserve-env.conf.j2 +++ b/angie/conf.dist/core-preserve-env.conf.j2 @@ -1,3 +1,34 @@ -{% for v in os.getenv('NGX_CORE_ENV', '').split(sep=' ') -%} +{#- prologue -#} +{%- set penv = [] -%} +{%- if cfg.preserve_env -%} + {%- set penv = cfg.preserve_env -%} + {%- if penv is string -%} + {%- set penv = [penv] -%} + {%- elif penv is iterable -%} + {#- {%- set penv = penv -%} -#} + {%- else -%} + {%- set penv = [penv|string()] -%} + {%- endif -%} +{%- endif -%} +{%- set have = namespace() -%} +{%- set have.tz = false -%} +{%- set have.malloc_arena = false -%} +{#- scan -#} +{%- for v in penv -%} + {%- set have.tz = have.tz or re.match('TZ(=|$)', v|string()) -%} + {%- set have.malloc_arena = have.malloc_arena or re.match('MALLOC_ARENA_MAX(=|$)', v|string()) -%} +{%- endfor -%} +{#- main part -#} +{%- if not have.tz -%} +env TZ; +{% endif %} +{%- if not have.malloc_arena -%} +env MALLOC_ARENA_MAX; +{% endif %} +{%- for v in penv -%} + {%- if re.search("(\"|'|\\s)", v|string()) %} +env {{ (v|string()).__repr__() }}; + {%- else %} env {{ v }}; -{% endfor -%} + {%- endif %} +{%- endfor -%} diff --git a/image-entry.d/01-defaults.envsh b/image-entry.d/01-defaults.envsh index cabece1..900a129 100755 --- a/image-entry.d/01-defaults.envsh +++ b/image-entry.d/01-defaults.envsh @@ -14,8 +14,6 @@ NGX_CORE_MODULES="${NGX_CORE_MODULES:-}" NGX_CORE_EVENTS_SNIPPETS="${NGX_CORE_EVENTS_SNIPPETS:-}" NGX_CORE_SNIPPETS="${NGX_CORE_SNIPPETS:-}" -NGX_CORE_ENV="${NGX_CORE_ENV:-}" - NGX_PROCESS_STATIC=$(gobool_to_int "${NGX_PROCESS_STATIC:-0}" 0) set +a diff --git a/image-entry.d/12-core-env.envsh b/image-entry.d/12-core-env.envsh deleted file mode 100755 index 3fa283f..0000000 --- a/image-entry.d/12-core-env.envsh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -if [ -z "${NGX_CORE_ENV:-}" ] ; then - NGX_CORE_ENV='TZ MALLOC_ARENA_MAX' -else - unset __set_f - __set_f= - case "${-}" in - *f* ) __set_f=1 ;; - esac - [ -n "${__set_f}" ] || set -f - - unset __env __have_tz __have_malloc - for __env in ${NGX_CORE_ENV} ; do - case "${__env}" in - TZ | TZ=* ) - __have_tz=1 - ;; - MALLOC_ARENA_MAX | MALLOC_ARENA_MAX=* ) - __have_malloc=1 - ;; - esac - done - unset __env - - [ -n "${__have_malloc}" ] || NGX_CORE_ENV="MALLOC_ARENA_MAX ${NGX_CORE_ENV}" - [ -n "${__have_tz}" ] || NGX_CORE_ENV="TZ ${NGX_CORE_ENV}" - unset __have_tz __have_malloc - - [ -n "${__set_f}" ] || set +f - unset __set_f -fi - -export NGX_CORE_ENV diff --git a/image-entry.d/13-core-worker-defaults.envsh b/image-entry.d/12-core-worker-defaults.envsh similarity index 100% rename from image-entry.d/13-core-worker-defaults.envsh rename to image-entry.d/12-core-worker-defaults.envsh