About env directive

Hi.

I want to enable the definition of custom environment variables in
mod_wsgi.

After a quick search in Nginx sources I have found the env directive and
the ngx_set_environment function.

Unfortunately the documentation is in Russian only
Основная функциональность.

I have found some problems with this directive.

  • It seems that it is not possible to inherit enviroment variables
    from the “system”;
    only variables defined with env directive are added to os environment
  • The syntax should be
    env VAR|VAR=VALUE,
    but, as an example,
    env MALLOC_OPTIONS;
    does not put MALLOC_OPTIONS in the environment.

Thanks Manlio P.

On Mon, Nov 26, 2007 at 05:49:28PM +0100, Manlio P. wrote:

from the “system”;
only variables defined with env directive are added to os environment

  • The syntax should be
    env VAR|VAR=VALUE,
    but, as an example,
    env MALLOC_OPTIONS;
    does not put MALLOC_OPTIONS in the environment.

“env VAR” inherits VAR from initial environment.
However, some variables affects before nginx will remove from or add
to new environment.

Igor S. ha scritto:

I have found some problems with this directive.

  • It seems that it is not possible to inherit enviroment variables
    from the “system”;
    only variables defined with env directive are added to os environment
  • The syntax should be
    env VAR|VAR=VALUE,
    but, as an example,
    env MALLOC_OPTIONS;
    does not put MALLOC_OPTIONS in the environment.

“env VAR” inherits VAR from initial environment.

Ok, thanks.
So it is not possible to inherits all vars from initial environment.

This seems reasonable, but I’m not sure that disabling implicit
inheritance of vars from initial environment is always good.

However, some variables affects before nginx will remove from or add
to new environment.

This should not be a problem.
I call ngx_set_environment before Py_Initialize.

Manlio P.