MatrixSynapse/synapse/app
Eric Eastwood d19d1edbcf
Print full startup/initialization error (#15569)
I found the error in the **Before** really vague and obtuse and didn't realize port `5432` corresponded to the Postgres port until searching the codebase. It says to check the logs but that wasn't my first instinct. It's just more obvious if we just print the full thing which gives context of the error type and the traceback to the relevant area of code.

#### Before

```
$ poetry run python -m synapse.app.homeserver -c homeserver.yaml
**********************************************************************************
 Error during initialisation:
    connection to server at "localhost" (::1), port 5432 failed: Connection refused
 	Is the server running on that host and accepting TCP/IP connections?
 connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
 	Is the server running on that host and accepting TCP/IP connections?
 
 There may be more information in the logs.
**********************************************************************************
```

#### After

```sh
$ poetry run python -m synapse.app.homeserver -c homeserver.yaml
**********************************************************************************
 Error during initialisation:
     Traceback (most recent call last):
       File "/home/eric/Documents/github/element/synapse/synapse/app/homeserver.py", line 352, in setup
         hs.setup()
       File "/home/eric/Documents/github/element/synapse/synapse/server.py", line 337, in setup
         self.datastores = Databases(self.DATASTORE_CLASS, self)
       File "/home/eric/Documents/github/element/synapse/synapse/storage/databases/__init__.py", line 65, in __init__
         with make_conn(database_config, engine, "startup") as db_conn:
       File "/home/eric/Documents/github/element/synapse/synapse/storage/database.py", line 161, in make_conn
         native_db_conn = engine.module.connect(**db_params)
       File "/home/eric/.cache/pypoetry/virtualenvs/matrix-synapse-xCtC9ulO-py3.10/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
         conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
     psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused
     	Is the server running on that host and accepting TCP/IP connections?
     connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
     	Is the server running on that host and accepting TCP/IP connections?
 
 
 There may be more information in the logs.
**********************************************************************************
```
2023-05-11 11:50:46 -05:00
..
__init__.py Use importlib.metadata to read requirements (#12088) 2022-03-01 17:44:41 +00:00
_base.py Print full startup/initialization error (#15569) 2023-05-11 11:50:46 -05:00
admin_cmd.py Add information on uploaded media to user export command. (#15107) 2023-02-23 13:14:17 -05:00
appservice.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
client_reader.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
complement_fork_starter.py Bump black from 22.12.0 to 23.1.0 (#15103) 2023-02-22 15:29:09 -05:00
event_creator.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
federation_reader.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
federation_sender.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
frontend_proxy.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
generic_worker.py Experimental Unix socket support (#15353) 2023-04-03 10:27:51 +01:00
homeserver.py Experimental Unix socket support (#15353) 2023-04-03 10:27:51 +01:00
media_repository.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
phone_stats_home.py Return read-only collections from `@cached` methods (#13755) 2023-02-10 23:29:00 +00:00
pusher.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
synchrotron.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00
user_dir.py Refactor entry points so that they all have a `main` function. (#13052) 2022-06-14 17:41:06 +00:00