From 1153a5d6a67082d1848aca4e74341c6cfc6eda10 Mon Sep 17 00:00:00 2001 From: Yavuz Kaymak <53019867+yavuzkaymak@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:09:42 +0100 Subject: [PATCH 1/3] 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. --- app/start.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/start.sh b/app/start.sh index d703654e69..dccab91344 100755 --- a/app/start.sh +++ b/app/start.sh @@ -1,5 +1,7 @@ #!/bin/sh +cd "${0%/*}" || exit 1 + cd ../ echo 'Creating python virtual environment ".venv"' python3 -m venv .venv @@ -9,9 +11,10 @@ echo "Restoring backend python packages" echo "" ./.venv/bin/python -m pip install -r app/backend/requirements.txt -if [ $? -ne 0 ]; then +out=$? +if [ $out -ne 0 ]; then echo "Failed to restore backend python packages" - exit $? + exit $out fi echo "" @@ -20,9 +23,10 @@ echo "" cd app/frontend npm install -if [ $? -ne 0 ]; then +out=$? +if [ $out -ne 0 ]; then echo "Failed to restore frontend npm packages" - exit $? + exit $out fi echo "" @@ -30,9 +34,10 @@ echo "Building frontend" echo "" npm run build -if [ $? -ne 0 ]; then +out=$? +if [ $out -ne 0 ]; then echo "Failed to build frontend" - exit $? + exit $out fi echo "" @@ -44,7 +49,8 @@ cd ../backend port=50505 host=localhost ../../.venv/bin/python -m quart --app main:app run --port "$port" --host "$host" --reload -if [ $? -ne 0 ]; then +out=$? +if [ $out -ne 0 ]; then echo "Failed to start backend" - exit $? + exit $out fi From 422402a27a012407aa94cc8aaf0d06a2fedff70a Mon Sep 17 00:00:00 2001 From: Yavuz Kaymak <53019867+yavuzkaymak@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:14:14 +0100 Subject: [PATCH 2/3] doc: add comment explaining why we cd into the parent folder in start.sh --- app/start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/start.sh b/app/start.sh index dccab91344..68fbec173c 100755 --- a/app/start.sh +++ b/app/start.sh @@ -1,5 +1,7 @@ #!/bin/sh +# cd into the parent directory of the script, +# so that the script generates virtual environments always in the same path. cd "${0%/*}" || exit 1 cd ../ From bc3b7f92cc2b5a4bea60fe040cda98f5867ba263 Mon Sep 17 00:00:00 2001 From: Yavuz Kaymak <53019867+yavuzkaymak@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:27:39 +0100 Subject: [PATCH 3/3] set the parent of the script as current location --- app/start.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/start.ps1 b/app/start.ps1 index 00e4ce379c..294f3608ac 100644 --- a/app/start.ps1 +++ b/app/start.ps1 @@ -1,3 +1,6 @@ +# set the parent of the script as the current location. +Set-Location $PSScriptRoot + Write-Host "" Write-Host "Loading azd .env file from current environment" Write-Host ""