Skip to content

Commit 1153a5d

Browse files
authored
Update start.sh
- the codes cds into its folder which makes it possible to run script from any directory - saves the return code from previous commands to a variable and returns it at exit. Without saving the exit code into a variable exit $? return the return code of the echo statement which is always 0.
1 parent 009d5e1 commit 1153a5d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

app/start.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
cd "${0%/*}" || exit 1
4+
35
cd ../
46
echo 'Creating python virtual environment ".venv"'
57
python3 -m venv .venv
@@ -9,9 +11,10 @@ echo "Restoring backend python packages"
911
echo ""
1012

1113
./.venv/bin/python -m pip install -r app/backend/requirements.txt
12-
if [ $? -ne 0 ]; then
14+
out=$?
15+
if [ $out -ne 0 ]; then
1316
echo "Failed to restore backend python packages"
14-
exit $?
17+
exit $out
1518
fi
1619

1720
echo ""
@@ -20,19 +23,21 @@ echo ""
2023

2124
cd app/frontend
2225
npm install
23-
if [ $? -ne 0 ]; then
26+
out=$?
27+
if [ $out -ne 0 ]; then
2428
echo "Failed to restore frontend npm packages"
25-
exit $?
29+
exit $out
2630
fi
2731

2832
echo ""
2933
echo "Building frontend"
3034
echo ""
3135

3236
npm run build
33-
if [ $? -ne 0 ]; then
37+
out=$?
38+
if [ $out -ne 0 ]; then
3439
echo "Failed to build frontend"
35-
exit $?
40+
exit $out
3641
fi
3742

3843
echo ""
@@ -44,7 +49,8 @@ cd ../backend
4449
port=50505
4550
host=localhost
4651
../../.venv/bin/python -m quart --app main:app run --port "$port" --host "$host" --reload
47-
if [ $? -ne 0 ]; then
52+
out=$?
53+
if [ $out -ne 0 ]; then
4854
echo "Failed to start backend"
49-
exit $?
55+
exit $out
5056
fi

0 commit comments

Comments
 (0)