aws elastic beanstalk deployment error

hello,
I am trying to delpoy my website, after following the documentation and deploying it I get health erorr.

what I did:

  • collected static
  • made requirements.txt
  • zipped the code like so:
    image
  • added the static handling at the urls,
urlpatterns = [
    path('admin/', admin.site.urls),
    path("",include("main_website.urls")),

] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) \
    + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)

while ben_gurion_bkal is the main folder (the one that contains the wsgi file) and main_website is the one and only application.

the logs:
https://drive.google.com/drive/folders/10BV20UJajuziClZufJQ1diLBVFkuZeOT?usp=sharing

aws:

thanks in advance

Hi eyalyakir159,

Looking at the web std out logs, the first section is what you need to be concerned about:

Oct 21 11:55:30 ip-172-31-40-9 web: [2021-10-21 11:55:30 +0000] [3491] [INFO] Starting gunicorn 20.1.0
Oct 21 11:55:30 ip-172-31-40-9 web: [2021-10-21 11:55:30 +0000] [3491] [INFO] Listening at: http://127.0.0.1:8000 (3491)
Oct 21 11:55:30 ip-172-31-40-9 web: [2021-10-21 11:55:30 +0000] [3491] [INFO] Using worker: gthread
Oct 21 11:55:30 ip-172-31-40-9 web: [2021-10-21 11:55:30 +0000] [3546] [INFO] Booting worker with pid: 3546
Oct 21 11:55:30 ip-172-31-40-9 web: [2021-10-21 11:55:30 +0000] [3546] [ERROR] Exception in worker process
Oct 21 11:55:30 ip-172-31-40-9 web: Traceback (most recent call last):
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Oct 21 11:55:30 ip-172-31-40-9 web: worker.init_process()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Oct 21 11:55:30 ip-172-31-40-9 web: super().init_process()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Oct 21 11:55:30 ip-172-31-40-9 web: self.load_wsgi()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Oct 21 11:55:30 ip-172-31-40-9 web: self.wsgi = self.app.wsgi()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Oct 21 11:55:30 ip-172-31-40-9 web: self.callable = self.load()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Oct 21 11:55:30 ip-172-31-40-9 web: return self.load_wsgiapp()
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Oct 21 11:55:30 ip-172-31-40-9 web: return util.import_app(self.app_uri)
Oct 21 11:55:30 ip-172-31-40-9 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
Oct 21 11:55:30 ip-172-31-40-9 web: mod = importlib.import_module(module)
Oct 21 11:55:30 ip-172-31-40-9 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Oct 21 11:55:30 ip-172-31-40-9 web: return _bootstrap._gcd_import(name[level:], package, level)
Oct 21 11:55:30 ip-172-31-40-9 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Oct 21 11:55:30 ip-172-31-40-9 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Oct 21 11:55:30 ip-172-31-40-9 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Oct 21 11:55:30 ip-172-31-40-9 web: ModuleNotFoundError: No module named 'application'

What that’s saying is that when gunicorn attempts to run your application, it can’t find the module named application.

How are you configuring the application to run? Depending on where you’re running it from you may need to include a prefix of ben_gurion_bkal

sorry for not understaind, its my first time lunching an application.
what do you mean configuring the application to run?
if I got it right, the wsgi file should do the job,


which is at ben_gurion_bkal\wsgi.py.
and at django config I call it like so

The django.config file is what I was referring to.

I think the AWS docs may be wrong. The django docs indicate you don’t have to specify the :application

Try:

WSGIPath: ben_gurion_bkal.wsgi

Admittedly, I haven’t worked with EBS before, so I’m not 100% sure.

Thank you so much!!!
cant explain how happy I am now :slight_smile:

another question about aws.
when I deploy my application my code looks like so:
image
when the db is a file containing some basic stuff, say the admin user, the upload folder is empty (when user uploads stuff it goes there) and the rest is the static code.
after i deploy my code how can i acsses the db/files from aws? say I want to dowlond the db and change it and then reupload it?
basicly how can I acsses the server files
thanks!

That’s an AWS question which is outside of my knowledge base. You’ll be better suited looking for a forum that’s tailored to their services for that particular question, unless someone else here has knowledge about it.

Hi Tim,

For me is very hard to access to the EB files , y advice you to a external database like mysql o postgres. And alternative can be this library
django-s3-sqlite, but only if you a very slow traffic.

Regars,

Hello Tim,

I am trying to deploy a django app (rather project) onto AWS EB.
After all the struggle finally reached a point which I do not get any help on the web. Will be nice if you can look into this and advise or direct to another forum/thread(if required)

As mentioned in the first line, I am trying to deploy my entire project which has the default app and other apps also installed. These other apps are also provided in the INSTALLED_APPS properties in settings.py
This setup works well on local.
But as I deploy it on AWS, it throws, “module not found” error for the first custom app in the list of INSTALLED_APPS.
The below snapshot should explain it all (the green lines are supporting apps, blue line is main app, also the .ebextension config and settings.py are displayed)

And below is the error from the AWS EB → “web.stdout.log” file (error line in bold)
##########################################
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “/var/app/venv/staging-LQM1lest/lib64/python3.11/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: django.setup(set_prefix=False)
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “/var/app/venv/staging-LQM1lest/lib64/python3.11/site-packages/django/init.py”, line 24, in setup
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: apps.populate(settings.INSTALLED_APPS)
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “/var/app/venv/staging-LQM1lest/lib64/python3.11/site-packages/django/apps/registry.py”, line 91, in populate
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: app_config = AppConfig.create(entry)
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: ^^^^^^^^^^^^^^^^^^^^^^^
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “/var/app/venv/staging-LQM1lest/lib64/python3.11/site-packages/django/apps/config.py”, line 193, in create
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: import_module(entry)
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “/usr/lib64/python3.11/importlib/init.py”, line 126, in import_module
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: return _bootstrap._gcd_import(name[level:], package, level)
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “”, line 1204, in _gcd_import
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “”, line 1176, in _find_and_load
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: File “”, line 1140, in _find_and_load_unlocked
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: ModuleNotFoundError: No module named ‘OrderMgmt’
Jan 17 13:59:20 ip-172-31-7-2 web[4809]: [2024-01-17 13:59:20 +0000] [4809] [INFO] Worker exiting (pid: 4809)
Jan 17 13:59:20 ip-172-31-7-2 web[4805]: [2024-01-17 13:59:20 +0000] [4805] [ERROR] Worker (pid:4809) exited with code 3
Jan 17 13:59:20 ip-172-31-7-2 web[4805]: [2024-01-17 13:59:20 +0000] [4805] [ERROR] Shutting down: Master
Jan 17 13:59:20 ip-172-31-7-2 web[4805]: [2024-01-17 13:59:20 +0000] [4805] [ERROR] Reason: Worker failed to boot.
##########################################

So any clues, hints or pointers for this will be extremely helpful for me.
Pls note - I am new to py and django and very new to AWS EB.
Another note - Yes, the AWS EB Django current doc is wrong in several places. I resolved the app/env creation errors by getting tips in several forums, plus, hit-try. Now, I am stuck in this phase!!

Thank you

You should create a separate thread for your question.

As you do that, you should confirm that your deployment is actually submitting these extra directories you expect it to. When faced with weird issues like these, it’s best to validate your assumptions.

I did create a new thread; hope to see some replies soon; I think I miss some configuration; but not able to find the same. Here is the link: