Using a file as a flag and proxy_pass to hang a server

Hello,

I would like to delay proxying a request for a few second, until the
server is ready.

To do this, I’m attempting to use recursion:

if (-f $document_root/block_writes) {
proxy_pass http://127.0.0.1;
break;
}

With this technique, I’m able to hang the request by doing:

touch document_root/block_writes

However if I do:

rm document_root/block_writes

the request is still hung.

Am I missing something? How do I get nginx to recheck if the file
exists?

Thank you,
Brian

Posted at Nginx Forum: