synapse/synapse
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
..
_scripts Add an admin API endpoint to support per-user feature flags (#15344) 2023-04-28 11:33:45 -07:00
api Stabilize MSC2659 support for AS ping endpoint. (#15528) 2023-05-09 15:02:36 -04:00
app Print full startup/initialization error (#15569) 2023-05-11 11:50:46 -05:00
appservice Stabilize MSC2659 support for AS ping endpoint. (#15528) 2023-05-09 15:02:36 -04:00
config Add redis SSL configuration options (#15312) 2023-05-11 13:02:51 +01:00
crypto Factor out an is_mine_server_name method (#15542) 2023-05-05 15:06:22 +01:00
events Move ThirdPartyEventRules into module_api/callbacks (#15535) 2023-05-04 14:18:22 +00:00
federation Factor out an is_mine_server_name method (#15542) 2023-05-05 15:06:22 +01:00
handlers Error if attempting to set m.push_rules account data, per MSC4010. (#15555) 2023-05-09 10:34:10 -04:00
http HTTP Replication Client (#15470) 2023-05-09 14:25:20 -04:00
logging
media Add config option to prevent media downloads from listed domains. (#15197) 2023-05-09 14:08:51 -04:00
metrics
module_api Move ThirdPartyEventRules into module_api/callbacks (#15535) 2023-05-04 14:18:22 +00:00
push Error if attempting to set m.push_rules account data, per MSC4010. (#15555) 2023-05-09 10:34:10 -04:00
replication Add redis SSL configuration options (#15312) 2023-05-11 13:02:51 +01:00
res Use oEmbed for YouTube Shorts (#15025) 2023-05-03 12:54:42 -04:00
rest Add an unstable feature flag for MSC3391 to the /versions endpoint (#15562) 2023-05-11 10:38:32 +01:00
server_notices
spam_checker_api
state
static
storage Clean up and clarify "Create or modify Account" Admin API documentation (#15544) 2023-05-05 15:51:46 +01:00
streams
types Implement MSC4009 to widen the allowed Matrix ID grammar (#15536) 2023-05-05 12:13:50 -04:00
util Clean up and clarify "Create or modify Account" Admin API documentation (#15544) 2023-05-05 15:51:46 +01:00
__init__.py
event_auth.py
notifier.py Move ThirdPartyEventRules into module_api/callbacks (#15535) 2023-05-04 14:18:22 +00:00
py.typed
server.py HTTP Replication Client (#15470) 2023-05-09 14:25:20 -04:00
visibility.py