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

François Battail fb at francois.battail.name
Wed Apr 30 01:27:28 MSD 2008

Rt Ibmer <rtibmx at ...> writes:

> >> if (fork() == 0)
> >  > execl("/bin/sh","/path/to/upstream_down.sh","ID of down upsteam 
> >>goes here", NULL);
> >It's not as easy to do.
> At a high level, what am I missing / oversimplifying?

The problem is not at high level but at low level: you cannot put code like this
on a server, it's not a matter of writing two lines but to test potential
errors, to have clean configuration parameters and to maintain the software...

> Perhaps instead, a simpler and more efficient approach may be for me to write
to a log when nginx stops routing requests to an upstream box. I cannot use the
events it logs current, because it doesn't differentiate between a failed
attempt vs. enough failed attempts based on max_fails and fail_timeout.

Yes, it could be a solution but not good engineering: log is mostly for
post-mortem investigations not for processing live events. It's dangerous to
rely on string patterns.

> Perfect! I just need the hook.

Some input from the list will be appreciated, I believe that such a module will
add value to Nginx but some time is needed in order to fully evaluate the
implications and the best implementation.

> Thank you for your consideration and I hope these discussions help make in
incredible product even more robust.


More information about the nginx mailing list