diff --git a/app/lib/database/database.dart b/app/lib/database/database.dart index 9fb0a36f4d..9994f78f14 100644 --- a/app/lib/database/database.dart +++ b/app/lib/database/database.dart @@ -129,19 +129,13 @@ Future<(String, String?)> _startOrUseLocalPostgresInDocker() async { throw StateError('Missing connection URL in Appengine environment.'); } - final socketFile = File('/tmp/pub_dev_postgres/run/.s.PGSQL.5432'); - // the default connection URL for local server final url = Uri( scheme: 'postgresql', path: 'postgres', userInfo: 'postgres:postgres', queryParameters: { - // If the socket file is present, let's try to use it, otherwise connect through the port. - // Both has benefits: - // - (during startup) calling the port is a blocking call and waits until the service is started, - // - (while the service is running) the socket file seems to provide a bit faster connection. - 'host': await socketFile.exists() ? socketFile.path : 'localhost:55432', + 'host': '.dart_tool/postgresql/run/.s.PGSQL.5432', 'sslmode': 'disable', 'max_connection_count': '8', }, diff --git a/app/tool/start-local-postgres.sh b/app/tool/start-local-postgres.sh index 91cd537c90..ec570a99bc 100755 --- a/app/tool/start-local-postgres.sh +++ b/app/tool/start-local-postgres.sh @@ -8,7 +8,7 @@ set -e SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -PG_TEMP_DIR="${TMPDIR:-/tmp}/pub_dev_postgres/" +PG_TEMP_DIR="${SCRIPT_DIR}/../.dart_tool/postgresql/" mkdir -p "${PG_TEMP_DIR}" # Create directory for exposing sockets @@ -29,7 +29,6 @@ CONTAINER_ID=$(( -e POSTGRES_PASSWORD=postgres \ -v "${SCRIPT_DIR}/docker-postgres-timeout-entrypoint.sh":/pub-entrypoint.sh \ -v "${SOCKET_DIR}":/var/run/postgresql/ \ - -p 55432:5432 \ --mount type=tmpfs,destination=/var/lib/postgresql/data \ --entrypoint /pub-entrypoint.sh \ postgres:17 \