Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions app/lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
3 changes: 1 addition & 2 deletions app/tool/start-local-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down