What are people doing with regards to putting their Phoenix applications into maintenance mode when they need to make changes, or because a backend service is down?
Some sort of proxy ‘switch’ - ie nginx
A command that somehow switches it off?
Seperate storage that is queried each request? (redis, sqlite etc)
I’d suggest handling that in a layer above phoenix. A.k.a. any reverse proxy or loadbalancer you might have. If you don’t have both of those you probably don’t run a distributed setup, where a simple plug and a GenServer holding the state would probably be enough to limit access in the endpoint.
I handle this at the reverse proxy by forwarding all requests to a static HTML site. With NGINX, I put my production config in /etc/nginx/conf.d/my-application.conf and the maintenance config into /etc/nginx/conf.d/my-application.maintenance.conf.off: NGINX will ignore this file because it doesn’t end with conf. To activate the maintenance mode, just rename the two files: