# Buggy code
def main():
    app.run(host="0.0.0.0", port=8080, threaded=True)


# Traceback (ServerSelectionTimeoutError)
[Sat Jun 20 12:53:00.260834 2015] [:error] [pid 19124:tid 140441230903040] 2015-06-20 12:53:00,260 - alerta.app[19124]: INFO - Starting alerta version 4.4.7 ...
[Sat Jun 20 12:53:00.322813 2015] [:error] [pid 19124:tid 140441230903040] 2015-06-20 12:53:00,322 - alerta.app[19124]: DEBUG - Connected to mongodb://localhost:27017/monitoring
[Sat Jun 20 12:53:30.368402 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204] mod_wsgi (pid=19124): Target WSGI script '/var/www/api.wsgi' cannot be loaded as Python module.
[Sat Jun 20 12:53:30.369482 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204] mod_wsgi (pid=19124): Exception occurred processing WSGI script '/var/www/api.wsgi'.
[Sat Jun 20 12:53:30.369865 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204] Traceback (most recent call last):
[Sat Jun 20 12:53:30.370266 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/var/www/api.wsgi", line 4, in <module>
[Sat Jun 20 12:53:30.370691 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     from alerta.app import app as application
[Sat Jun 20 12:53:30.370976 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/alerta/app/__init__.py", line 49, in <module>
[Sat Jun 20 12:53:30.371371 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     db = Mongo()
[Sat Jun 20 12:53:30.371839 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/alerta/app/database.py", line 81, in __init__
[Sat Jun 20 12:53:30.372459 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     self.version = self.db.collection_names()
[Sat Jun 20 12:53:30.372813 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/pymongo/database.py", line 488, in collection_names
[Sat Jun 20 12:53:30.373313 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     ReadPreference.PRIMARY) as (sock_info, slave_okay):
[Sat Jun 20 12:53:30.373520 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
[Sat Jun 20 12:53:30.373826 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     return self.gen.next()
[Sat Jun 20 12:53:30.374027 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/pymongo/mongo_client.py", line 699, in _socket_for_reads
[Sat Jun 20 12:53:30.374501 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     with self._get_socket(read_preference) as sock_info:
[Sat Jun 20 12:53:30.374706 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
[Sat Jun 20 12:53:30.374978 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     return self.gen.next()
[Sat Jun 20 12:53:30.375184 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/pymongo/mongo_client.py", line 663, in _get_socket
[Sat Jun 20 12:53:30.375440 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     server = self._get_topology().select_server(selector)
[Sat Jun 20 12:53:30.375661 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/pymongo/topology.py", line 121, in select_server
[Sat Jun 20 12:53:30.376016 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     address))
[Sat Jun 20 12:53:30.376039 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]   File "/opt/alerta/lib/python2.7/site-packages/pymongo/topology.py", line 97, in select_servers
[Sat Jun 20 12:53:30.376062 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204]     self._error_message(selector))
[Sat Jun 20 12:53:30.376095 2015] [:error] [pid 19124:tid 140441230903040] [remote 192.168.0.1:8204] ServerSelectionTimeoutError: No servers found yet

# Fixed code
def main():
    app.logger.info("Starting alerta version %s ...", __version__)
    app.logger.info("Using MongoDB version %s ...", db.get_version())
    app.run(host="0.0.0.0", port=8080, threaded=True)