internal server error while deploying django app - django

I am getting a 500 internal server error while deploying a django app to aws. I cannot find any error in activity log.The nevironment is created and the app is deployed successfully but it is showing this error when I am trying to run it. Can someone please help me to fix the issue ?
I have added both the text and images of the error log. Thanks.
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[Mon May 28 14:23:48.433306 2018] [:error] [pid 4775] [remote 172.31.30.246:204] return _bootstrap._gcd_import(name[level:], package, level)
[Mon May 28 14:23:48.433311 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Mon May 28 14:23:48.433316 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Mon May 28 14:23:48.433321 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Mon May 28 14:23:48.433325 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Mon May 28 14:23:48.433330 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap_external>", line 674, in exec_module
[Mon May 28 14:23:48.433335 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap_external>", line 781, in get_code
[Mon May 28 14:23:48.433339 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
[Mon May 28 14:23:48.433344 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Mon May 28 14:23:48.433357 2018] [:error] [pid 4775] [remote 172.31.30.246:204] File "/opt/python/current/app/totaliQ/settings.py", line 29
[Mon May 28 14:23:48.433364 2018] [:error] [pid 4775] [remote 172.31.30.246:204] ALLOWED_HOSTS = [vir-env1.kkhhumhvum.us-west-2.elasticbeanstalk.com]
[Mon May 28 14:23:48.433392 2018] [:error] [pid 4775] [remote 172.31.30.246:204] ^
[Mon May 28 14:23:48.433399 2018] [:error] [pid 4775] [remote 172.31.30.246:204] SyntaxError: invalid syntax
[Mon May 28 14:23:54.617673 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] mod_wsgi (pid=4775): Target WSGI script '/opt/python/current/app/totaliQ/wsgi.py' cannot be loaded as Python module.
[Mon May 28 14:23:54.617721 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] mod_wsgi (pid=4775): Exception occurred processing WSGI script '/opt/python/current/app/totaliQ/wsgi.py'.
[Mon May 28 14:23:54.617965 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] Traceback (most recent call last):
[Mon May 28 14:23:54.618019 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/current/app/totaliQ/wsgi.py", line 16, in <module>
[Mon May 28 14:23:54.618023 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] application = get_wsgi_application()
[Mon May 28 14:23:54.618029 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Mon May 28 14:23:54.618033 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] django.setup(set_prefix=False)
[Mon May 28 14:23:54.618038 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Mon May 28 14:23:54.618041 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon May 28 14:23:54.618046 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
[Mon May 28 14:23:54.618049 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] self._setup(name)
[Mon May 28 14:23:54.618054 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
[Mon May 28 14:23:54.618066 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] self._wrapped = Settings(settings_module)
[Mon May 28 14:23:54.618071 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
[Mon May 28 14:23:54.618075 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon May 28 14:23:54.618079 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Mon May 28 14:23:54.618082 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] return _bootstrap._gcd_import(name[level:], package, level)
[Mon May 28 14:23:54.618087 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Mon May 28 14:23:54.618092 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Mon May 28 14:23:54.618097 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Mon May 28 14:23:54.618102 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Mon May 28 14:23:54.618107 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap_external>", line 674, in exec_module
[Mon May 28 14:23:54.618111 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap_external>", line 781, in get_code
[Mon May 28 14:23:54.618116 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
[Mon May 28 14:23:54.618121 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Mon May 28 14:23:54.618146 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] File "/opt/python/current/app/totaliQ/settings.py", line 29
[Mon May 28 14:23:54.618154 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] ALLOWED_HOSTS = [vir-env1.kkhhumhvum.us-west-2.elasticbeanstalk.com]
[Mon May 28 14:23:54.618206 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] ^
[Mon May 28 14:23:54.618213 2018] [:error] [pid 4775] [remote 172.31.30.246:15820] SyntaxError: invalid syntax
[Mon May 28 14:24:00.753060 2018] [:error] [pid 4775] [remote 172.31.30.246:200] mod_wsgi (pid=4775): Target WSGI script '/opt/python/current/app/totaliQ/wsgi.py' cannot be loaded as Python module.
[Mon May 28 14:24:00.753109 2018] [:error] [pid 4775] [remote 172.31.30.246:200] mod_wsgi (pid=4775): Exception occurred processing WSGI script '/opt/python/current/app/totaliQ/wsgi.py'.
[Mon May 28 14:24:00.753272 2018] [:error] [pid 4775] [remote 172.31.30.246:200] Traceback (most recent call last):
[Mon May 28 14:24:00.753323 2018] [:error] [pid 4775] [remote 172.31.30.246:200] File "/opt/python/current/app/totaliQ/wsgi.py", line 16, in <module>
-------------------------------------
/var/log/eb-activity.log
-------------------------------------
inflating: /opt/python/ondeck/app/vir-env/Scripts/pip.exe
inflating: /opt/python/ondeck/app/vir-env/Scripts/pip3.6.exe
inflating: /opt/python/ondeck/app/vir-env/Scripts/pip3.exe
inflating: /opt/python/ondeck/app/vir-env/Scripts/pyexpat.pyd
inflating: /opt/python/ondeck/app/vir-env/Scripts/python.exe
inflating: /opt/python/ondeck/app/vir-env/Scripts/python3.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/python36.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/pythonw.exe
inflating: /opt/python/ondeck/app/vir-env/Scripts/select.pyd
inflating: /opt/python/ondeck/app/vir-env/Scripts/sqlite3.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/tcl86t.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/tk86t.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/ucrtbase.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/unicodedata.pyd
inflating: /opt/python/ondeck/app/vir-env/Scripts/vccorlib140.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/vcomp140.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/vcruntime140.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/winsound.pyd
inflating: /opt/python/ondeck/app/vir-env/Scripts/xlwings32-0.11.5.dll
inflating: /opt/python/ondeck/app/vir-env/Scripts/xlwings64-0.11.5.dll
extracting: /opt/python/ondeck/app/vir-env/pip-selfcheck.json
inflating: /opt/python/ondeck/app/vir-env/pyvenv.cfg
[2018-05-28T14:23:07.865Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/AppDeployPreHook/03deploy.py] : Starting activity...
[2018-05-28T14:23:08.526Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/AppDeployPreHook/03deploy.py] : Completed activity. Result:
Requirement already satisfied: Django==2.0.5 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 1))
Requirement already satisfied: django-appconf==1.0.2 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 2))
Requirement already satisfied: django-bootstrap3==10.0.1 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 3))
Requirement already satisfied: django-multiselectfield==0.1.8 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 4))
Requirement already satisfied: django-rest-framework==0.1.0 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 5))
Requirement already satisfied: django-select2==6.0.2 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 6))
Requirement already satisfied: djangorestframework==3.8.2 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 7))
Requirement already satisfied: pytz==2018.4 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 8))
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[2018-05-28T14:23:08.526Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/AppDeployPreHook/04configen.py] : Starting activity...
[2018-05-28T14:23:09.919Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/AppDeployPreHook/04configen.py] : Completed activity.
[2018-05-28T14:23:09.919Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2018-05-28T14:23:09.919Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2018-05-28T14:23:10.310Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
[2018-05-28T14:23:10.310Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
[2018-05-28T14:23:10.325Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/EbExtensionPostBuild] : Completed activity.
[2018-05-28T14:23:10.325Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/InfraCleanEbextension] : Starting activity...
[2018-05-28T14:23:10.358Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0/InfraCleanEbextension] : Completed activity.
Result:
Cleaned ebextensions subdirectories from /opt/python/ondeck/app.
[2018-05-28T14:23:10.358Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage0] : Completed activity. Result:
Application update - Command CMD-AppDeploy stage 0 completed
[2018-05-28T14:23:10.359Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage1] : Starting activity...
[2018-05-28T14:23:10.359Z] INFO [4604] - [Application update app-29a6-180528_115229#4/AppDeployStage1/AppDeployEnactHook] : Starting activity...
]2]3]4

Traceback points to invalid syntax in line:
ALLOWED_HOSTS = [vir-env1.kkhhumhvum.us-west-2.elasticbeanstalk.com]
Hosts are strings and should therefore be in quotes:
ALLOWED_HOSTS = ['vir-env1.kkhhumhvum.us-west-2.elasticbeanstalk.com']

Related

Error In Deploying Fastapi api to aws elastic beanstalk

I am trying to deploy my fastapi api to aws elastic beanstalk, I zipped my code file app.py with the requirements.txt and .ebextensions folder that contains config file with the following: option_settings:
aws:elasticbeanstalk:application:environment:
PYTHONPATH: "/var/app/current:$PYTHONPATH"
aws:elasticbeanstalk:container:python:
WSGIPath: "app:app"
but I am getting the following error:
Feb 1 16:48:27 ip-172-31-45-195 web: [2023-02-01 16:48:27 +0000] [14516] [ERROR] Error handling request /
Feb 1 16:48:27 ip-172-31-45-195 web: Traceback (most recent call last):
Feb 1 16:48:27 ip-172-31-45-195 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 271, in handle
Feb 1 16:48:27 ip-172-31-45-195 web: keepalive = self.handle_request(req, conn)
Feb 1 16:48:27 ip-172-31-45-195 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 323, in handle_request
Feb 1 16:48:27 ip-172-31-45-195 web: respiter = self.wsgi(environ, resp.start_response)
Feb 1 16:48:27 ip-172-31-45-195 web: TypeError: call() missing 1 required positional argument: 'send'
any help
I tried to play with the config file but nothing worked

SAM build from GitHub actions suddenly failing today: module 'lib' has no attribute 'OpenSSL_add_all_algorithms

Yesterday, my SAM build was working with the below GitHub actions. Today it suddenly started failing with an error:
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
The SAM template doesn't have any error which I have validated; are any others facing this issue?
name: SAM deploy
on:
push:
branches:
- main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-python#v3
- uses: aws-actions/setup-sam#v2
- uses: aws-actions/configure-aws-credentials#v1
with:
aws-access-key-id: ${{ secrets.MY_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.MY_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: SAM Build
run: sam build --use-container --template-file source/deploy-template.yml
- name: SAM Deploy
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name my-stack --resolve-s3 --capabilities CAPABILITY_IAM --region us-west-2 --parameter-overrides Environment=npd
GitHub actions error details for the SAM build
Traceback (most recent call last):
496
File "/home/runner/work/_temp/setup-sam-PFBc7r/bin/sam", line 8, in <module>
497
sys.exit(cli())
498
^^^^^
499
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
500
return self.main(*args, **kwargs)
501
^^^^^^^^^^^^^^^^^^^^^^^^^^
502
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1055, in main
503
rv = self.invoke(ctx)
504
^^^^^^^^^^^^^^^^
505
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1651, in invoke
506
cmd_name, cmd, args = self.resolve_command(ctx, args)
507
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
508
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/click/core.py", line 1698, in resolve_command
509
cmd = self.get_command(ctx, cmd_name)
510
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
511
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/cli/command.py", line 133, in get_command
512
mod = importlib.import_module(pkg_name)
513
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
514
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/importlib/__init__.py", line 126, in import_module
515
return _bootstrap._gcd_import(name[level:], package, level)
516
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
517
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
518
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
519
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
520
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
521
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
522
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
523
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/build/__init__.py", line 6, in <module>
524
from .command import cli # noqa
505
^^^^^^^^^^^^^^^^^^^^^^^^
506
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/build/command.py", line 12, in <module>
507
from samcli.commands._utils.options import (
508
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/_utils/options.py", line 21, in <module>
509
from samcli.commands._utils.template import get_template_data, TemplateNotFoundException
510
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/samcli/commands/_utils/template.py", line 10, in <module>
511
from botocore.utils import set_value_from_jmespath
512
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/botocore/utils.py", line 37, in <module>
513
import botocore.httpsession
514
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/botocore/httpsession.py", line 46, in <module>
515
from urllib3.contrib.pyopenssl import (
516
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/urllib3/contrib/pyopenssl.py", line 50, in <module>
517
import OpenSSL.crypto
518
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/OpenSSL/__init__.py", line 8, in <module>
519
from OpenSSL import crypto, SSL
520
File "/home/runner/work/_temp/setup-sam-PFBc7r/.venv/lib/python3.11/site-packages/OpenSSL/crypto.py", line 3268, in <module>
521
_lib.OpenSSL_add_all_algorithms()
522
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
523
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
524
Error: Process completed with exit code 1.
I validated the SAM template
I also tried sudo apt install python3-openssl in the GitHub actions, but it didn't work.
Running this command worked for me:
pip install pyopenssl --upgrade
It started working again after downgrading the version of aws-actions/setup-sam#v2. The issue is with the cryptography version 39.0.0 which was released 13hrs ago; the latest version SAM uses this version, and during the SAM build we are noticing an error.
Refer to the PyPi release history: https://pypi.org/project/cryptography/38.0.4/#history
So whoever using aws-actions/setup-sam#v2 should point back to the SAM version to 1.59.0 which could be a temporary fix:
name: SAM deploy
on:
push:
branches:
- main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-python#v3
- uses: aws-actions/setup-sam#v2
with:
version: 1.59.0
- uses: aws-actions/configure-aws-credentials#v1
with:
aws-access-key-id: ${{ secrets.MY_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.MY_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: SAM Build
run: sam build --use-container --template-file source/deploy-template.yml
- name: SAM Deploy
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name my-stack --resolve-s3 --capabilities CAPABILITY_IAM --region us-west-2 --parameter-overrides Environment=npd
Please run this command:
pip3 install --force-reinstall cryptography==38.0.4
or
pip3 install --upgrade cryptography==38.0.4
cryptography 39.0.0 no longer supports openssl 1.1.0 or older and thus is causing this issue.
https://cryptography.io/en/latest/changelog/#v39-0-0

AWS Beanstalk Deployment Failing Due to WSGIPath

I'm trying to deploy a Django application the AWS ElasticBeanstalk. However, my deployments are failing due to a possible error in WSGIPath. Here is my configuration in /.ebextensions:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "conf.settings"
"PYTHONPATH": "/var/app/current:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: conf.wsgi:application
NumProcesses: 1
NumThreads: 15
Here is the error that I encounter:
/var/log/web.stdout.log
----------------------------------------
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Oct 28 04:17:54 ip-172-31-9-159 web: worker.init_process()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Oct 28 04:17:54 ip-172-31-9-159 web: super().init_process()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Oct 28 04:17:54 ip-172-31-9-159 web: self.load_wsgi()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Oct 28 04:17:54 ip-172-31-9-159 web: self.wsgi = self.app.wsgi()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Oct 28 04:17:54 ip-172-31-9-159 web: self.callable = self.load()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Oct 28 04:17:54 ip-172-31-9-159 web: return self.load_wsgiapp()
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Oct 28 04:17:54 ip-172-31-9-159 web: return util.import_app(self.app_uri)
Oct 28 04:17:54 ip-172-31-9-159 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/util.py", line 363, in import_app
Oct 28 04:17:54 ip-172-31-9-159 web: raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
Oct 28 04:17:54 ip-172-31-9-159 web: ImportError: Failed to find application, did you mean 'conf/wsgi:application'?
My app structure looks basically like this:
backend-app/
├─ .ebextensions/
├─ conf/
│ ├─ settings.py
│ ├─ wsgi.py
│ ├─ ...
├─ my-app/
│ ├─ ....
├─ manage.py
I have tried multiple ways of specifying the WSGIPath according to some online resources, and the suggestion the error gives. I've tried changing it to conf/wsgi.py, conf.wsgi.application, conf/wsgi, conf.wsgi, conf.wsgi:application, and conf/wsgi:application. I'm not sure how to approach this issue. Thanks in advance.

Run cron job with curl to execute django command management

I have a command management that I should run daily at midnight, I usually execute it from my pc, I want to create a cronjob that can do this automatically
here the command that I execute from my local environment:
env=application; kubectl exec -ti $(kubectl get pods| grep $env| awk '{print $1}') -c "application" -- ./manage.py daily_job
and here the corn job yml file that I wrote:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: update-client-tasks
labels:
environment: application
spec:
schedule: "0 0 * * *"
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: update-client-tasks
image: gcr.io/application-156608/application:v0.5.32
args:
- /usr/bin/curl --data "key=$CRON_KEY" http://application/code/ | env=application; kubectl exec -ti $(kubectl get pods| grep $env| awk '{print $1}') -c "application" -- ./manage.py daily_job
env:
- name: CRON_KEY
valueFrom:
secretKeyRef:
name: application-secrets
key: cronKey
when running this corn job I got this error:
2021-06-22 09:00:24.184 JSTTraceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File "/usr/local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/usr/local/lib/python3.8/site-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django_extensions'
please any help will be very useful
N.B: update
and to resolve this problem of django extensions
I changed the args in the yaml file
args:
- /usr/bin/curl --data "key=$CRON_KEY" http://application/code/ | env=application; kubectl exec -ti $(kubectl get pods| grep $env| awk '{print $1}') -c "application" -- pip3 install django-extensions && python3 manage.py daily_job
I got this error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/usr/local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_extensions'
some have downvoted my question due to lack of explication and unclear details,
I really apologize about that, as myself, do not understand well kubernetes and having troubles to understand the documentation

How deploy Django Project with Bitbucket Pipelines and AWS Elastic Beanstalk?

I have a django project running perfect in AWS Elastic Beanstalk in awsgi mode.
I want add an pipeline from Bitbucket to simplify deploy process.
bitbucket-pipelines.yml
image: atlassian/default-image:2
pipelines:
default:
- step:
name: "Build and Test"
script:
- echo "Everything is awesome!"
- apt-get update
- apt-get install -y zip
- zip application.zip application/*
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
S3_BUCKET: $S3_BUCKET
APPLICATION_NAME: $APPLICATION_NAME
ENVIRONMENT_NAME: $APPLICATION_ENVIRONMENT
COMMAND: 'upload-only'
ZIP_FILE: 'application.zip'
artifacts:
- application.zip
- step:
name: "Deploy to Production"
deployment: production
script:
- echo "Deployment to Production!"
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: $APPLICATION_NAME
ENVIRONMENT_NAME: $APPLICATION_ENVIRONMENT
COMMAND: 'deploy-only'
WAIT: 'true'
I make a new folder called application and put all my Django project inside.
Bitbucket pipelines works fine but show 502 error.
#edit
/var/log/web.stdout.log
web: Traceback (most recent call last):
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
web: worker.init_process()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
web: super().init_process()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
web: self.load_wsgi()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
web: self.wsgi = self.app.wsgi()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
web: self.callable = self.load()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
web: return self.load_wsgiapp()
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
web: return util.import_app(self.app_uri)
web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
web: mod = importlib.import_module(module)
web: File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
web: return _bootstrap._gcd_import(name[level:], package, level)
web: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
web: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
web: File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
web: ModuleNotFoundError: No module named 'application'
.ebextensions/django_config.conf
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: 'myproject.wsgi:application'