# Env lost effect in single process mode

**URL:** <https://www.ruby-forum.com/t/env-lost-effect-in-single-process-mode/200477>\
**Category:** NGINX\
**Created:** [December 13, 2010, 8:43am UTC](https://www.ruby-forum.com/t/env-lost-effect-in-single-process-mode/200477 "2010-12-13T08:43:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 13, 2010, 8:43am UTC](https://www.ruby-forum.com/t/env-lost-effect-in-single-process-mode/200477/1 "2010-12-13T08:43:04Z")

</div>

Hey, I find when I set daemon off and master\_process off to enter the  
dev single process mode, env simply doesn’t work. My custom module  
depending on that env can’t find them. So I check the code and find in  
ngx\_single\_process\_cycle, ngx\_set\_environment is not invoked. So I add  
it like fellow code. Maybe u can fix this little bug in your main nginx  
branch.

```auto
void
ngx_single_process_cycle(ngx_cycle_t *cycle)
{
    ngx_uint_t i;

    if (ngx_set_environment(cycle, NULL) == NULL) { <--- add this code
            /* fatal */
            exit(2);
    }

    for (i = 0; ngx_modules[i]; i++) {
        if (ngx_modules[i]->init_process) {
            if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
                /* fatal */
                exit(2);
            }
        }
    }
```

Posted at Nginx Forum:

> **[env lost effect in single process mode](https://forum.nginx.org/read.php?2,158113,158113#msg-158113)**
>
> Hey, I find when I set daemon off and master\_process off to enter the dev single process mode, env simply doesn't work. My custom module depending on that env can't find them. So I check the code and find in ngx\_single\_process\_cycle,...

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 13, 2010, 11:55am UTC](https://www.ruby-forum.com/t/env-lost-effect-in-single-process-mode/200477/2 "2010-12-13T11:55:11Z")

</div>

On Mon, Dec 13, 2010 at 02:42:06AM -0500, speedfirst wrote:

> {  
> /\* fatal \*/  
> exit(2);  
> }  
> }  
> }  
> [/code]

OK, I will add it in 0.9.3, however, please note that single process  
mode  
was never intended to run in production: there are issues related to  
reconfiguration (HUP signal).

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 14, 2010, 3:21am UTC](https://www.ruby-forum.com/t/env-lost-effect-in-single-process-mode/200477/3 "2010-12-14T03:21:30Z")

</div>

Yes, I just want dev and prodcution mode behave same

Posted at Nginx Forum:

> **[Re: env lost effect in single process mode](https://forum.nginx.org/read.php?2,158113,158412#msg-158412)**
>
> Hey, I find when I set daemon off and master\_process off to enter the dev single process mode, env simply doesn't work. My custom module depending on that env can't find them. So I check the code and find in ngx\_single\_process\_cycle,...
