My site uses two app server, namely app1 and app2, so in the configuration I have something like this:
upstream cluster {
server app1:8080;
server app2:8080;
}
Since every time I update the code I need to restart both server processes and I want the service undisturbed, I will follow these steps manually:
Comment
app1
within upstream block so to modify it into:upstream cluster { #server app1:8080; server app2:8080; }
Run
nginx -s reload
Update code at
app1
and restart the server program, and then uncommentapp1
in upstream blockDo steps 1-3 for
app2
I wish to write a script to spare this tedious work, so what I hope to do is this:
Have a folder named "available" which contains
app1.conf
andapp2.conf
in form asserver app1:8080;
Have another folder named "enabled" to contain the soft links of
app1.conf
andapp2.conf
Modify the upstream cluster into
upstream cluster { include /usr/local/nginx/conf/enabled/*; }
So every time I need to disable any app server I can just remove the corresponding soft link from the "enabled" folder, and later can restore it by running
ln -s
However this approach didn't work well as I got an error message from nginx saying:
[emerg]: "include" directive is not allowed here in ....
Is that so include
cannot not be put into the upstream block? and I'd imagine I'm not alone in this kind of scenario, disabling and enabling server at times, how other folks normally deal with it?