2024-01-30 11:32:02 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2024-02-08 16:04:56 +00:00
|
|
|
# You have to add the following lines to /etc/hosts to make this work:
|
|
|
|
#
|
|
|
|
# 127.0.0.1 ibis-alpha
|
|
|
|
# 127.0.0.1 ibis-beta
|
|
|
|
#
|
2024-02-09 13:46:33 +00:00
|
|
|
# Then run this script and open http://ibis-alpha:8090/, http://ibis-beta:8091/ in your browser.
|
2024-02-08 16:04:56 +00:00
|
|
|
|
2024-02-09 10:30:44 +00:00
|
|
|
function cleanup {
|
|
|
|
echo "stop postgres"
|
2024-02-09 13:46:33 +00:00
|
|
|
./scripts/stop_dev_db.sh $ALPHA_DB_PATH >/dev/null
|
|
|
|
./scripts/stop_dev_db.sh $BETA_DB_PATH >/dev/null
|
2024-02-09 10:30:44 +00:00
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
2024-02-08 16:04:56 +00:00
|
|
|
DB_FOLDER="$(pwd)/target/federation_db"
|
|
|
|
mkdir -p "$DB_FOLDER/"
|
|
|
|
ALPHA_DB_PATH="$DB_FOLDER/alpha"
|
|
|
|
BETA_DB_PATH="$DB_FOLDER/beta"
|
|
|
|
|
2024-02-09 10:30:44 +00:00
|
|
|
# create db folders if they dont exist
|
|
|
|
if [ ! -d $ALPHA_DB_PATH ]; then
|
2024-02-09 13:46:33 +00:00
|
|
|
./scripts/start_dev_db.sh $ALPHA_DB_PATH >/dev/null
|
2024-02-09 10:30:44 +00:00
|
|
|
else
|
2024-02-09 13:46:33 +00:00
|
|
|
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$ALPHA_DB_PATH" -D "$ALPHA_DB_PATH/dev_pgdata" >/dev/null
|
2024-02-09 10:30:44 +00:00
|
|
|
fi
|
|
|
|
if [ ! -d $BETA_DB_PATH ]; then
|
2024-02-09 13:46:33 +00:00
|
|
|
./scripts/start_dev_db.sh $BETA_DB_PATH >/dev/null
|
2024-02-09 10:30:44 +00:00
|
|
|
else
|
2024-02-09 13:46:33 +00:00
|
|
|
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$BETA_DB_PATH" -D "$BETA_DB_PATH/dev_pgdata" >/dev/null
|
2024-02-09 10:30:44 +00:00
|
|
|
fi
|
2024-02-08 16:04:56 +00:00
|
|
|
|
|
|
|
ALPHA_DB_URL="postgresql://ibis:password@/ibis?host=$ALPHA_DB_PATH"
|
|
|
|
BETA_DB_URL="postgresql://ibis:password@/ibis?host=$BETA_DB_PATH"
|
2024-02-09 13:46:33 +00:00
|
|
|
echo $ALPHA_DB_URL
|
2024-02-08 16:04:56 +00:00
|
|
|
|
|
|
|
# get rid of processes leftover from previous runs
|
|
|
|
killall ibis || true
|
|
|
|
|
2024-02-09 09:58:39 +00:00
|
|
|
CARGO_TARGET_DIR=target/frontend trunk build
|
|
|
|
|
2024-02-09 10:30:44 +00:00
|
|
|
# launch a couple of local instances to test federation, then wait for processes to finish
|
2024-02-09 13:46:33 +00:00
|
|
|
IBIS__BIND=127.0.0.1:8090 IBIS__FEDERATION__DOMAIN=ibis-alpha:8090 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run &
|
2024-02-09 10:30:44 +00:00
|
|
|
PID_ALPHA=($!)
|
2024-02-09 13:46:33 +00:00
|
|
|
IBIS__BIND=127.0.0.1:8091 IBIS__FEDERATION__DOMAIN=ibis-beta:8091 IBIS__DATABASE_URL=$BETA_DB_URL cargo run &
|
2024-02-09 10:30:44 +00:00
|
|
|
PID_BETA=($!)
|
2024-02-09 10:08:57 +00:00
|
|
|
|
2024-02-09 10:30:44 +00:00
|
|
|
wait $PID_ALPHA
|
|
|
|
wait $PID_BETA
|