allow instances to be marked unavailable

Add in middleware to check if an instance has been marked as unavailable
and a script to change the setting

Fixes #516
Set API to use alternative db if required