-
Notifications
You must be signed in to change notification settings - Fork 47
/
run-api.sh
executable file
·57 lines (40 loc) · 1.27 KB
/
run-api.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
#!/bin/bash
# Usage
# used for running the API and necessary services (dynamo, s3, elasticsearch) locally
npm run build:assets
# these exported values expire when script terminates
# shellcheck disable=SC1091
. ./setup-local-env.sh
export ELASTICSEARCH_HOST=elasticsearch
URL=http://elasticsearch:9200/ ./wait-until.sh
echo "creating elasticsearch index"
npm run seed:elasticsearch
echo "killing s3rver if already running"
pkill -f s3rver
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 dynamo tables"
npm run seed:db
exitCode=$?
fi
if [ "${exitCode}" != 0 ]; then
echo "Failed to seed data!". 1>&2 && exit 1
fi
if [[ -z "${RUN_DIR}" ]]; then
RUN_DIR="src"
fi
nodemon -e js,ts --ignore web-client/ --ignore dist/ --ignore dist-public/ --ignore cypress-integration/ --ignore cypress-smoketests/ --ignore cypress-readonly --exec "npx ts-node --transpile-only web-api/src/app-local.ts"
if [ ! -e "$CI" ]; then
echo "killing dynamodb local"
pkill -P "${DYNAMO_PID}"
pkill -P "${ESEARCH_PID}"
fi
pkill -P $S3RVER_PID
echo "API running..."