Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Django manage.py shell commands on elastic beanstalk on AL2

I have my Django service up and running on AWS Elastic Beanstalk (on Amazon Linux 2). eb deploy works perfectly. But I would like to run some functions from shell of Django on by eb or maybe perform migrations on my DB.

I am unable to find my package after I eb ssh <environment-name> so cant find the manage.py file.

Related question - Run manage.py from AWS EB Linux instance

I believe it might be outdated ?

like image 204
Aditya Nambiar Avatar asked Dec 01 '22 13:12

Aditya Nambiar


1 Answers

Change to the current app directory

cd /var/app/current/

Change to the staging app directory (only exists after a failed eb deploy)

cd /var/app/staging/

Activate the virtual env

source $(find /var/app/venv/*/bin/activate)

Load your environment variables

export $(sudo cat /opt/elasticbeanstalk/deployment/env | xargs)

Now you can run management commands

python manage.py shell

like image 182
Aditya Nambiar Avatar answered Dec 04 '22 05:12

Aditya Nambiar