Feature request: Run a script when upstream detected down/up

Manlio Perillo manlio_perillo at libero.it
Tue Apr 29 01:37:59 MSD 2008


Cliff Wells ha scritto:
> [...]
>> The beauty of it is that it seems like quite a trivial yet very useful
>> function to implement.  Basically where ever the code is that decides
>> to ignore an upstream for fail_timeout, it just needs to call out to
>> some script to launch it and pass it a param like the name of the
>> upstream entity that went down.  Seems like something that could be
>> done in just minutes.  Unfortunately I'm not a coder or I would take a
>> crack at it.
> 
> Except that Nginx is asynchronous, not threaded.  This means that when
> your script is called, Nginx will now be delayed while the script is
> launched (and what if the script fails?).  

Nginx will just have to wait until fork returns.

As you say, there no "immediate" way to know if the script fails, but 
Nginx installs a SIGCHLD handler, so you will get NOTICE messages in the 
log file: "%unknown process <pid> exited with code <status>"


For the OP, executing a script when a backend fails is trivial, it 
should be possibile to do it just be adding a new module.

However executing a script when a backend became alive again is not 
easy, as far as I know.

> You might be able to work
> around this, but I suspect it won't be as trivial as you might hope.
> 
> Regards,
> Cliff
> 
> 


Regards  Manlio Perillo





More information about the nginx mailing list