Make check-token robust against bad DB

This causes check-token to report 503 Service Unavailable if mongo is slow
to respond or if there is a database connection error. Errors are also
logged to stderr.