27 messages in ru.sysoev.nginxRe: Feature request: Run a script whe...
FromSent OnAttachments
Rt IbmerApr 28, 2008 8:44 am 
Cliff WellsApr 28, 2008 10:20 am 
mikeApr 28, 2008 11:53 am 
Rt IbmerApr 28, 2008 2:02 pm 
Cliff WellsApr 28, 2008 2:18 pm 
Manlio PerilloApr 28, 2008 2:37 pm 
Rt IbmerApr 28, 2008 6:10 pm 
Rt IbmerApr 28, 2008 6:19 pm 
Manlio PerilloApr 29, 2008 1:18 am 
Manlio PerilloApr 29, 2008 1:25 am 
Rt IbmerApr 29, 2008 8:11 am 
François BattailApr 29, 2008 10:46 am 
Rt IbmerApr 29, 2008 1:41 pm 
Manlio PerilloApr 29, 2008 1:57 pm 
François BattailApr 29, 2008 2:27 pm 
Aleksandar LazicApr 29, 2008 2:36 pm 
François BattailApr 29, 2008 11:20 pm 
Mansoor PeerbhoyApr 30, 2008 1:46 am 
Manlio PerilloApr 30, 2008 2:36 am 
François BattailApr 30, 2008 3:54 am 
Mansoor PeerbhoyApr 30, 2008 5:03 am 
Grzegorz NosekApr 30, 2008 5:18 am 
Cliff WellsApr 30, 2008 10:40 am 
Manlio PerilloApr 30, 2008 12:16 pm 
Manlio PerilloMay 1, 2008 2:42 am 
Grzegorz NosekMay 1, 2008 11:28 am 
Manlio PerilloMay 1, 2008 12:02 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Feature request: Run a script when upstream detected down/upActions...
From:Manlio Perillo (manl@public.gmane.org)
Date:Apr 28, 2008 2:37:36 pm
List:ru.sysoev.nginx

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