Skip to content

Commit f360483

Browse files
committed
chore(scripts): add scripts to run common commands
1 parent 968fdb0 commit f360483

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

scripts/run/engine-postgres.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
6+
7+
if ! command -v nc >/dev/null 2>&1; then
8+
echo "error: required command 'nc' not found."
9+
exit 1
10+
fi
11+
12+
if ! nc -z localhost 5432 >/dev/null 2>&1; then
13+
echo "Postgres is not reachable at localhost:5432."
14+
echo "Hint: run scripts/dev/run-postgres.sh to start the local Postgres container."
15+
exit 1
16+
fi
17+
18+
cd "${REPO_ROOT}"
19+
20+
RIVET__POSTGRES__URL=postgres://postgres:postgres@localhost:5432/postgres \
21+
RUST_LOG=debug \
22+
cargo run --bin rivet-engine -- start "$@"

scripts/run/postgres.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
CONTAINER_NAME="rivet-engine-postgres"
5+
POSTGRES_IMAGE="postgres:17"
6+
7+
if docker ps --all --format '{{.Names}}' | grep -qw "${CONTAINER_NAME}"; then
8+
if docker ps --format '{{.Names}}' | grep -qw "${CONTAINER_NAME}"; then
9+
docker stop "${CONTAINER_NAME}" >/dev/null 2>&1 || true
10+
fi
11+
docker rm "${CONTAINER_NAME}" >/dev/null 2>&1 || true
12+
fi
13+
14+
docker run \
15+
--detach \
16+
--name "${CONTAINER_NAME}" \
17+
--publish 5432:5432 \
18+
--env POSTGRES_PASSWORD=postgres \
19+
--env POSTGRES_USER=postgres \
20+
--env POSTGRES_DB=postgres \
21+
"${POSTGRES_IMAGE}"

0 commit comments

Comments
 (0)