I am using Python 3.7 Django 3.0.9 postgresql 11
-ebextension/django.config
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
02_compilemessages:
command: "django-admin.py compilemessages"
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: config.wsgi:application
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: config.settings
Error message when running eb deploy
2020-08-04 14:48:51 INFO Environment update is starting.
2020-08-04 14:49:30 INFO Deploying new version to instance(s).
2020-08-04 14:49:45 ERROR [Instance: i-0719a2ed67b621907] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
2020-08-04 14:49:45 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-08-04 14:49:45 ERROR Unsuccessful command execution on instance id(s) 'i-0719a2ed67b621907'. Aborting the operation.
2020-08-04 14:49:45 ERROR Failed to deploy application.
eb logs error content
2020/08/04 11:35:55.132182 ERROR Requirements file provided! Importing into Pipfile…
2020/08/04 11:35:56.227858 ERROR Error occurred during build: Command 01_migrate failed
2020/08/04 11:35:56.227884 ERROR An error occurred during execution of command app-deploy - PostBuildEbExtension. Stop running the command. Error: Container commands build failed. Please refer to /var/log/cfn-init.log for more details.
After checking the command 01_migrate failed message, it seems that there is a problem with the continer commands, so I ran django-admin migrate.
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I have defined environment variables in django.config, but there is an error, I cannot deploy my site django-admin migrate is replaced by python manage.py migrate but still doesn't deploy You can also find the detailed code on my GitHub
https://github.com/dopza86/air_bnb_clone
I don't know how to do it, I need your help,thank you
When your container_commands
command run, you won't be in your python's environment. Also make sure that env variables are set before your container_commands
run.
For this you can modify your .ebextentions
:
01-env_var.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: config.wsgi:application
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: config.settings
05-packages.config
packages:
yum:
postgresql-devel: []
10-django.config
container_commands:
01_migrate:
command: |
env # just to print out the env variables for checking in logs
source $PYTHONPATH/activate
django-admin.py migrate
leader_only: true
02_compilemessages:
command: |
env # just to print out the env variables for checking in logs
source $PYTHONPATH/activate
django-admin.py compilemessages
It seems like AWS has changed the way to customize the nginx reverse proxy and buried the documentation deep:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
In short, instead of using .ebextensions
with a files:
directive, one needs to create a nested path: .platform >.nginf > conf.d
, and place there the nginx customization .conf
files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.