# Main conf created twice, only closed once?

**URL:** <https://www.ruby-forum.com/t/main-conf-created-twice-only-closed-once/244277>\
**Category:** NGINX\
**Created:** [March 14, 2016, 12:01pm UTC](https://www.ruby-forum.com/t/main-conf-created-twice-only-closed-once/244277 "2016-03-14T12:01:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [March 14, 2016, 12:01pm UTC](https://www.ruby-forum.com/t/main-conf-created-twice-only-closed-once/244277/1 "2016-03-14T12:01:59Z")

</div>

Hi,  
I have a problem with a module I’m writing. I need to do something in  
the  
main config after variables are read from the conf file, so I have put  
this  
in the post\_conf function. Then I need do something when to it when the  
process is closed via  
./nginx -s reload  
this is in the exit\_process function. What I would expect is that for  
each  
reload there is one new main conf, this is not the case ( see output  
below  
). Two new main configs are created, then only one of them is ‘seen’ by  
the  
exit\_process.

create main conf mainconf=0x9908e8  
post conf mainconf=0x9908e8  
— reload happens  
create main conf mainconf=0xe508e8  
post conf mainconf=0xe508e8  
create main conf mainconf=0x993ef8  
post conf mainconf=0x993ef8  
exit mainconf=0x9908e8

So on reload, two new main configs are created, and the previous one is  
closed. This wouldn’t be a problem, but every subsequent reload the same  
thing happens ( two are created, but only one of the previous two  
exited).

Anyone have any idea why this might happen?

Thanks.

Posted at Nginx Forum:

> **[main conf created twice, only closed once?](https://forum.nginx.org/read.php?2,265302,265302#msg-265302)**
>
> Hi, I have a problem with a module I'm writing. I need to do something in the main config after variables are read from the conf file, so I have put this in the post\_conf function. Then I need do something when to it when the process is closed via...

---

<div class="post-metadata">

**Author:** ![ben5192](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e8c25b/32.png) [@ben5192](https://www.ruby-forum.com/u/ben5192)\
**Post date:** [March 14, 2016, 2:48pm UTC](https://www.ruby-forum.com/t/main-conf-created-twice-only-closed-once/244277/2 "2016-03-14T14:48:28Z")

</div>

Hello!

On Mon, Mar 14, 2016 at 07:01:42AM -0400, ben5192 wrote:

> closed. This wouldn’t be a problem, but every subsequent reload the same  
> thing happens ( two are created, but only one of the previous two exited).
> 
> Anyone have any idea why this might happen?

Are you using nginx on Windows? On Windows both master and worker  
processes read the configuration, as there is no fork().

Note well that the exit\_process callback is called on worker  
process exit, but not on exit of other processes. It’s not  
expected to be balanced with configuration creation.

–  
Maxim D.

> **[nginx](http://nginx.org/)**
