-
Notifications
You must be signed in to change notification settings - Fork 7
/
dev
executable file
·70 lines (54 loc) · 1.75 KB
/
dev
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
69
70
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail
set -Eeuo pipefail
# cd to script location
cd "$(dirname "${BASH_SOURCE[0]}")"
# source envrc if not already loaded
test -z "${ENVRC_LOADED:-}" && source ../.envrc
# cd to root location
cd ..
export LOGDIR=${LOGDIR:-$(mktemp -d)}
export BACKEND_LOG="$LOGDIR/backend.log"
print_logfiles() (
echo "Logfile directory: $LOGDIR"
echo "Backend logs: less +F $BACKEND_LOG"
)
cleanup() {
print_logfiles
trap - SIGTERM
kill -- -$$
}
# kill background jobs on exit
trap cleanup SIGINT SIGTERM EXIT
# prefix output to distinguish their source
prefix() {
prefix="$1"
color="$2"
colored_prefix="[$(tput setaf "$color")$prefix$(tput sgr0)] "
sed -u "s/^/$colored_prefix/"
}
./scripts/check-build-tools-and-ports
echo ""
print_logfiles | tee lastrun.log
echo ""
yarn install --frozen-lockfile
# npx runs commands installed by yarn.
# fun-local-env is part of github.com/fun-stack. fun-local-env simulates a local
# AWS (amazon cloud) environment. It simulates several services, for our case
# AWS-lambda, API-gateway, cognito. It allows us to develop for AWS infrastructure
# without the requirement to deploy to it during development.
(
echo "starting lambda backend"
(npx fun-local-env \
--auth $AUTH_PORT \
--http $HTTP_PORT \
--http-api lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js httpApi \
--http-rpc lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js httpRpc \
--ws $WS_PORT \
--ws-rpc lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js wsRpc \
|| kill 0) \
2>&1 | tee "$BACKEND_LOG" \
2>&1 | prefix "BACKEND" 4
) &
echo "starting webapp"
sbt dev shell