On Dec 20, 2011, at 10:51 PM, 한그루 wrote:
My customer wants to manage the backend server list dynamically. so if a
administrator add or remove some backend servers a program will write about it
into shared memory and send signal to nginx worker process to force to
synchronize with current server list.
writing out a new config file and doing a normal reload will accomplish
the same thing and it’s already done. No need to reinvent the wheel, I
don’t think. We manage the members of an upstream “dynamically” based
on our CMDB, so when we add or remove servers, the changes are reflected
in nginx and we did this without touching a line of nginx code.
On Wed, Dec 21, 2011 at 12:51:58PM +0900, 한그루 wrote:
process to force to synchronize with current server list. My question is (It's very hard to understand your code without kind comments and i don't have enough time to analyze it)
Is it ok if nginx process signal as soon as it delivered? or is there
any critical section where i should block signal?
Possible processing within signal handlers is limited.
First of all, usual programming rules apply: you are free to use
only functions which are marked as async-signal-safe in POSIX,
they are listed here:
Use of nginx own functions is restricted to a subset of functions
which only call async-signal-safe functions and don’t use shared
memory locking. There is no list of “safe” functions, i.e. before
using something in signal handler you have to carefully inspect it
to make sure it’s possible to use it in a signal handler.