Changeset View
Changeset View
Standalone View
Standalone View
api.sh
Show All 32 Lines | then | ||||
echo "Something is running on port 8000." | echo "Something is running on port 8000." | ||||
exit 2 | exit 2 | ||||
fi | fi | ||||
exit 0 # --norun exits successfully if its running already | exit 0 # --norun exits successfully if its running already | ||||
else | else | ||||
if [[ $1 = "--norun" ]] | if [[ $1 = "--norun" ]] | ||||
then | then | ||||
if which lsof >/dev/null | |||||
then | |||||
echo "Nothing is currently running on port 8000." | echo "Nothing is currently running on port 8000." | ||||
echo "You might need to run ./api.sh to launch the API." | echo "You might need to run ./api.sh to launch the API." | ||||
exit 1 # Failure | exit 1 # Failure | ||||
else | |||||
echo "Command 'lsof' is not installed, impossible to know if the API is running or not." | |||||
Hackintosh5: This is in --norun, it must not start the api | |||||
exit 1 | |||||
fi | |||||
fi | fi | ||||
echo "Setting up the submodule(s)..." | echo "Setting up the submodule(s)..." | ||||
git submodule init | git submodule init | ||||
git submodule update | git submodule update | ||||
echo "Checking if there is a new version of the API..." | echo "Checking if there is a new version of the API..." | ||||
cd api | cd api | ||||
git fetch origin master # Check if there are new commits, but don't merge them | git fetch origin master # Check if there are new commits, but don't merge them | ||||
git --no-pager log --decorate=short ..FETCH_HEAD # Display newer commits, if any | git --no-pager log --decorate=short ..FETCH_HEAD # Display newer commits, if any | ||||
cd api | cd api | ||||
if [[ ! -d "env" ]] | if [[ ! -d "env" ]] | ||||
then | then | ||||
echo "The virtual environment doesn't exist, creating it..." | echo "The virtual environment doesn't exist, creating it..." | ||||
virtualenv env | python3 -m venv env/ | ||||
fi | fi | ||||
echo "Running the virtual environment..." | echo "Running the virtual environment..." | ||||
source env/bin/activate | source env/bin/activate | ||||
echo "Installing requirements..." | echo "Installing requirements..." | ||||
python3.6 -m pip install -r requirements.txt | python3 -m pip install -r requirements.txt | ||||
echo "Preparing the database..." | echo "Preparing the database..." | ||||
rm db.sqlite3 | rm -f db.sqlite3 | ||||
Done Inline Actionsuse rm -f instead of test followed by delete. Hackintosh5: use rm -f instead of test followed by delete. | |||||
Done Inline ActionsIt's not about forcing, it's about not polluting the logs with "Could not remove db.sqlite3" when we don't care about it CLOVIS: It's not about forcing, it's about not polluting the logs with "Could not remove db.sqlite3"… | |||||
Done Inline Actions-f suppresses errors and accepts all queries. It's the right way to go as otherwise there's a risk (however tiny) that somehow db.sqlite3 is created in between. Also, -f is the 'right way'. Hackintosh5: -f suppresses errors and accepts all queries. It's the right way to go as otherwise there's a… | |||||
python3.6 manage.py migrate | python3 manage.py migrate | ||||
echo "Starting the development server..." | echo "Starting the development server..." | ||||
python3.6 manage.py sampledata | python3 manage.py sampledata | ||||
exec python3.6 manage.py runserver | python3 manage.py runserver & | ||||
Done Inline Actionsno need for an & as exec replaces the current process. if you want to run in the background remove exec Hackintosh5: no need for an & as exec replaces the current process. if you want to run in the background… | |||||
fi | fi |
This is in --norun, it must not start the api