########################################### ######### Running django ################## ###########################################
On terminal 1 cmd:
git clone xxx
cd main_project/django
source venv/bin/activate
pip install -r requirements.txt
- Change debug to TRUE in settings.py in Django
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver
On terminal 2 cmd:
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl status rabbitmq-server
On terminal 3 cmd:
celery -A core worker -B -l INFO
(If you want to run both separately, the code iscelery -A core worker -l info --pool=solo
andcelery -A core beat -l info
)
On URL: http://127.0.0.1:8000/reviews - test send of email
On terminal 1 cmd:
git clone xxx
cd main_project/django
source venv/bin/activate
pip install -r requirements.txt
deploy app
gcloud app deploy app.yaml celery_app.yaml
gcloud secrets versions add django_settings --data-file=.env.gcloud
Secret Manager
- search for secret manager and create a new version
- paste all the .env details into the secret manager and enable it
https://cloud.google.com/sql/docs/mysql/connect-app-engine Cloud sql
- search for "cloud sql" and create a new instance
- for each new instance - public ip - django settings sql - HOST
- Go to 'Users' and create a new user and password - USER - django settings sql - PASSWORD
- Go to 'Connections' - networking and "add a network" 0.0.0.0/0 so it can be access from public
- Go to 'Databases' and create a new database - django settings sql - NAME
- Make changes to the .env to update the SQL connections, PORT - 5432
Create and set up Google Cloud Storage - https://cloud.google.com/appengine/docs/flexible/serving-static-files?tab=custom#serving_files_from
avoid setting up the new bucket on the GUI, just do it via command line(Below), I tried GUI and it doesnt work
create a new bucket
gsutil mb gs://dj-static-19236
or
gsutil mb gs://<NAME>
grant access to items in bucket
gsutil defacl set public-read gs://dj-static-19236
or
gsutil defacl set public-read gs://<NAME>
upload items to bucket
gsutil -m rsync -r ./static gs://dj-static-19236/static
or
gsutil -m rsync -r ./static gs://<NAME>