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

Rt Ibmer rtibmx at yahoo.com
Tue Apr 29 19:11:38 MSD 2008

>There are no problems at spawing an external process.
>Simply, Nginx does not directly support this and you will get a lot of 
>NOTICE messages in the log when each process exits (even if it exits 
>with a success status code).

That is fine. Such "upstream server down" events should be rare and the extra notices in the logs will not impact things. 

>Personally I'm not interested in this feature, sorry.
>I have given a look in the Nginx source code and it seems that all you 
>want is implementable, and it should require only a few hours of coding.

Thank you. Can you provide a hint as to what .c file(s) I would need to modify and what types of system calls I should look at? Maybe all I need to do is find the spot where nginx deems it should skip a downed server, and immediately after that add this code:
if (fork() == 0)
  execl("/bin/sh","/path/to/upstream_down.sh","ID of down upsteam goes here", NULL);

Or should I be using the system() function?

Any other considerations I need to worry about?

Also if I make this change might it be adopted and incorporated into the product? I would not want to have to keep applying my own patch every time I compile a new version of nginx and am happy to contribute my work to this excellent product and project. Thank you.

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

More information about the nginx mailing list