How to avoid restarting Apache proxy when you restart CouchDB
I'm running a localhost CouchDB instance using CouchDBX on my Mac, proxied behind Apache 2 using the ProxyPass
directive:
<VirtualHost *:80>
ServerName playlick # points to localhost in /etc/hosts
DocumentRoot "/Users/james/Sites/playlick"
ProxyPass /data http://localhost:5984
ProxyPassReverse /data http://localhost:5984
</VirtualHost>
If I try to hit my Couch instance at http://playlick/data
while it's not running I get a 503 Service Temporarily Unavailable error, as would be expected.
I then start up the Couch server and hit the same URL, but I still get the error until I restart the Apache proxy.
If on the other hand, I start up the Couch instance before hitting that URL, everything works fine without having to touch Apache.
So it seems as though the 503 error is cached until the Apache process is restarted. How do I stop this from happening?
OR, if that's not possible, how do I force Apache to restart when I start up the Couch instance in the CouchDBX GUI app?
I believe what you need to be looking at is the retry option that you can pass with the ProxyPass directive.
retry default: 60 seconds
Connection pool worker retry timeout in seconds. If the connection pool worker to the backend server is in the error state, Apache will not forward any requests to that server until the timeout expires. This enables to shut down the backend server for maintenance, and bring it back online later. A value of 0 means always retry workers in an error state with no timeout.