forked from invertase/react-native-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-firebase-emulator.sh
More file actions
executable file
·44 lines (37 loc) · 1.53 KB
/
Copy pathstart-firebase-emulator.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.53 KB
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
#!/bin/bash
# shellcheck source=firebase-cli.sh
source "$(dirname "$0")/firebase-cli.sh"
# firebase.json must use single-database Firestore config — the emulator does not load
# security rules from the multi-database array format (firebase.deploy.json).
EMU_START_COMMAND=("${FIREBASE_CMD[@]}" emulators:start --config firebase.json --only auth,database,firestore,functions,storage --project react-native-firebase-testing)
#EMU_START_COMMAND="sleep 120"
MAX_RETRIES=3
MAX_CHECKATTEMPTS=60
CHECKATTEMPTS_WAIT=1
# Make sure functions are ready to go
pushd "$(dirname "$0")/functions" && yarn && yarn build && popd
RETRIES=1
while [ $RETRIES -le $MAX_RETRIES ]; do
if [ "$1" == "--no-daemon" ]; then
echo "Starting Firebase Emulator Suite in foreground."
"${EMU_START_COMMAND[@]}"
exit 0
else
echo "Starting Firebase Emulator Suite in background."
"${EMU_START_COMMAND[@]}" &
CHECKATTEMPTS=1
while [ $CHECKATTEMPTS -le $MAX_CHECKATTEMPTS ]; do
sleep $CHECKATTEMPTS_WAIT
if curl --output /dev/null --silent --fail http://localhost:8080; then
echo "Firebase Emulator Suite is online!"
exit 0;
fi
echo "Waiting for Firebase Emulator Suite to come online, check $CHECKATTEMPTS of $MAX_CHECKATTEMPTS..."
((CHECKATTEMPTS = CHECKATTEMPTS + 1))
done
fi
echo "Firebase Emulator Suite did not come online in $MAX_CHECKATTEMPTS checks. Try $RETRIES of $MAX_RETRIES."
((RETRIES = RETRIES + 1))
done
echo "Firebase Emulator Suite did not come online after $MAX_RETRIES attempts."
exit 1