-
Notifications
You must be signed in to change notification settings - Fork 47
/
run-local.sh
executable file
·68 lines (51 loc) · 1.73 KB
/
run-local.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
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Used for running the API and necessary services (dynamo, s3, elasticsearch) locally
# shellcheck disable=SC1091
. ./setup-local-env.sh
if [[ -z "$CI" ]]; then
echo "Stopping dynamodb in case it's already running"
pkill -f DynamoDBLocal
echo "starting dynamo"
./web-api/start-dynamo.sh &
DYNAMO_PID=$!
echo "Stopping elasticsearch in case it's already running"
pkill -f elasticsearch
echo "Starting elasticsearch"
./web-api/start-elasticsearch.sh &
ESEARCH_PID=$!
URL=http://localhost:9200/ ./wait-until.sh
echo "Stopping s3rver in case it's already running"
pkill -f s3rver
fi
npm run build:assets
echo "Seeding elasticsearch"
npm run seed:elasticsearch
echo "Starting s3rver"
rm -rf ./web-api/storage/s3/*
npm run start:s3rver &
S3RVER_PID=$!
URL=http://0.0.0.0:9000/ ./wait-until.sh
npm run seed:s3
if [ -n "${RESUME}" ]; then
echo "Resuming operation with previous s3 and dynamo data"
else
echo "Creating & seeding dynamodb tables"
npm run seed:db
exitCode=$?
if [ "${exitCode}" != 0 ]; then
echo "Failed to seed data!". 1>&2 && exit 1
fi
fi
echo "Seeding cognito-local users"
npx ts-node .cognito/seedCognitoLocal.ts --transpile-only
echo "Starting cognito-local"
CODE="COGNITO_LOCAL_CONFIRMATION_CODE" npx cognito-local &
COGNITO_PID=$!
nodemon --delay 1 -e js,ts --ignore web-client/ --ignore dist/ --ignore dist-public/ --ignore cypress-integration/ --ignore cypress/helpers/ --ignore cypress-smoketests/ --ignore cypress-readonly --exec "npx ts-node --transpile-only web-api/src/app-local.ts"
if [[ -z "$CI" ]]; then
echo "Stopping dynamodb, elasticsearch, and s3rver"
pkill -P "$DYNAMO_PID"
pkill -P "$ESEARCH_PID"
pkill -P "$S3RVER_PID"
pkill -P "$COGNITO_PID"
fi