forked from timescale/promscale_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.sh
executable file
·56 lines (46 loc) · 1.71 KB
/
devenv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
trap 'trap "" SIGINT SIGTERM; kill 0' SIGINT SIGTERM EXIT
# Ensure that we have the correct postgres tools on path
export PATH="/usr/lib/postgresql/${DEVENV_PG_VERSION}/bin:${PATH}"
# Ensure that the correct postgres tools are available for `docker exec`
echo "PATH=${PATH}" >> ~/.bashrc
# Set sensible postgres env vars
export PGPORT="288${DEVENV_PG_VERSION}"
export PGHOST=localhost
# Set sensible postgres env vars for `docker exec`
echo "export PGPORT=${PGPORT}" >> ~/.bashrc
echo "export PGHOST=${PGHOST}" >> ~/.bashrc
wait_for_db() {
echo "waiting for DB"
for _ in $(seq 10) ; do
if pg_isready -d postgres -U postgres 1>/dev/null 2>&1; then
echo "DB up"
return 0
fi
echo -n "."
sleep 1
done
echo
echo "FAIL waiting for DB"
exit 1
}
cargo pgx start "pg${DEVENV_PG_VERSION}"
wait_for_db
for db in template1 postgres; do
psql -h localhost -U "$(whoami)" -p "${PGPORT}" -d $db -c 'CREATE EXTENSION IF NOT EXISTS timescaledb';
done
createdb -h localhost -p "${PGPORT}" "$(whoami)"
if [ "$DEVENV_ENTR" -eq 1 ]; then
echo "entr enabled. rebuilds will be triggered on source file changes"
# This allows entr to work correctly on docker for mac
export ENTR_INOTIFY_WORKAROUND=true
# Note: this is not a comprehensive list of source files, if you think one is missing, add it
SOURCE_FILES="src migration"
find ${SOURCE_FILES} | entr make devenv-internal-build-install > "${HOME}/compile.log" &
tail -f "${HOME}/.pgx/${DEVENV_PG_VERSION}.log" "${HOME}/compile.log" &
else
echo "entr disabled. you must trigger rebuilds manually with 'make dev-build'"
make devenv-internal-build-install
tail -f "${HOME}/.pgx/${DEVENV_PG_VERSION}.log"
fi
wait