AWS Beanstalk Deployment Failing Due to WSGIPath - django

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.

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

Grails 4: Mail plugin fails to read 'password' property when running on Elastic Beanstalk

My Grails 4 application runs fine locally but fails to send emails when I run it in Elastic Beanstalk. I'm using the runnable WAR file on Java 11 platform using the embedded (not external) Tomcat server.
I'm setting the grails.mail.password property externally via a GRAILS_MAIL_PASSWORD environment variable.
I'm checking the config value in BootStrap.groovy and in the EmailsService, and the value is properly set.
BootStrap
class BootStrap {
GrailsApplication grailsApplication
def init = { servletContext ->
String config = "\n"
grailsApplication.config.each {
config += " --> $it.key : ${grailsApplication.config.getProperty(it.key)}\n"
}
log.info(config)
EmailService
class EmailService {
#Value('${cloudcard.email.doNotSend}')
boolean doNotSend
#Value('${grails.mail.username}')
String grailsMailUsername
#Value('${grails.mail.password}')
String grailsMailPassword
#PostConstruct
void init() {
log.info("grailsMailUsername: ${grailsMailUsername.take(2)}****${grailsMailUsername.reverse().take(2).reverse()}")
log.info("grailsMailPassword: ${grailsMailPassword.take(4)}****${grailsMailPassword.reverse().take(4).reverse()}")
}
EmailService Log Output
Nov 16 02:48:32 ip-172-31-31-36 web: 2021-11-16 02:48:32.946 INFO --- [io-5000-exec-10] us.cloudcard.api.EmailService : grailsMailUsername: AK****G2
Nov 16 02:48:32 ip-172-31-31-36 web: 2021-11-16 02:48:32.946 INFO --- [io-5000-exec-10] us.cloudcard.api.EmailService : grailsMailPassword: BI****5Z
Nov 16 02:48:33 ip-172-31-31-36 web: 2021-11-16 02:48:33.311 ERROR --- [pool-4-thread-1] grails.plugins.mail.MailMessageBuilder : Failed to send email
Nov 16 02:48:33 ip-172-31-31-36 web: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException:
failed to connect, no password specified?
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:440)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:361)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:356)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSender$send$0.call(Unknown Source)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
Nov 16 02:48:33 ip-172-31-31-36 web: at grails.plugins.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy:124)
Nov 16 02:48:33 ip-172-31-31-36 web: at grails.plugins.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/java.lang.reflect.Method.invoke(Method.java:566)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
Nov 16 02:48:33 ip-172-31-31-36 web: at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
Nov 16 02:48:33 ip-172-31-31-36 web: at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
Nov 16 02:48:33 ip-172-31-31-36 web: at groovy.lang.Closure.call(Closure.java:405)
Nov 16 02:48:33 ip-172-31-31-36 web: at groovy.lang.Closure.call(Closure.java:399)
Nov 16 02:48:33 ip-172-31-31-36 web: at groovy.lang.Closure.run(Closure.java:486)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
Nov 16 02:48:33 ip-172-31-31-36 web: at java.base/java.lang.Thread.run(Thread.java:829)
Nov 16 02:48:33 ip-172-31-31-36 web: Caused by: javax.mail.AuthenticationFailedException: failed to connect, no password specified?
Nov 16 02:48:33 ip-172-31-31-36 web: at javax.mail.Service.connect(Service.java:400)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:518)
Nov 16 02:48:33 ip-172-31-31-36 web: at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:437)
Nov 16 02:48:33 ip-172-31-31-36 web: ... 22 common frames omitted
But...
...if I hardcode the username and password into application.groovy, everything works, and I receive the email in my inbox. I'm not sure if it matters, but this is one of the only things I have configured in application.groovy. Almost everything else is in application.yml.
Do you have any idea why the Grails Mail Plugin might be ignoring my external config?
As a workaround, I've redeployed the same application using the external Tomcat container platform (Amazon Linux 2; Tomcat 8.5; Corretto Java 11) and the application is now respecting the environment variables.

Django project docker after unexpected shutdown: Is the server running on host "db" (172.19.0.3) and accepting TCP/IP connections on port 5432?

I am using popOs20
Battery was running low and unexpected shutdown occurred. The same project with docker successfully gets built on other device.
I have tried:
docker system prune,
docker volume prune,
killing all processes of swap and ram and then restarting,
changing docker network and some other things I do not, even remember anymore.
Any ideas what can I do ?
Project is using postgresql13
full error:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection timed out
Is the server running on host "db" (172.19.0.3) and accepting
TCP/IP connections on port 5432?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 458, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations
if self.has_table():
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 260, in cursor
return self._cursor()
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 236, in _cursor
self.ensure_connection()
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/usr/local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection timed out
Is the server running on host "db" (172.19.0.3) and accepting
TCP/IP connections on port 5432?
docker-compose.yml:
version: "3.3"
services:
backend: &be
container_name: my_be
build:
context: ./backend
command: bash -c "python manage.py runserver 0.0.0.0:8080"
expose:
- 8080
volumes:
- "./backend:/code/"
depends_on:
- db
restart: unless-stopped
environment:
- DEBUG=1
- SECRET_KEY=7km0&m!ffj$n3bre-sdbc(97920(k$yfl^x992(t(s0zp)0jb8
- POSTGRES_DB=dev
- POSTGRES_USER=dev
- POSTGRES_PASSWORD=mysekretpassword
- POSTGRES_SERVICE_HOST=db
- POSTGRES_SERVICE_PORT=5432
- REDIS_PORT=6379
- REDIS_HOST=redis
- REDIS_DB=0
networks:
- main
db:
container_name: my_db
image: postgres:13-alpine
environment:
- POSTGRES_DB=dev
- POSTGRES_USER=dev
- POSTGRES_PASSWORD=mysekretpassword
networks:
- main
pgadmin:
container_name: my_pgadmin
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=admin#admin.com
- PGADMIN_DEFAULT_PASSWORD=admin
depends_on:
- db
ports:
- "5050:80"
networks:
- main
nginx:
container_name: my_nginx
build:
context: ./nginx
ports:
- "80:80"
depends_on:
- backend
volumes:
- ./nginx/dev.conf:/etc/nginx/nginx.conf:ro
restart: unless-stopped
networks:
- main
redis:
container_name: my_redis
image: redis:alpine
volumes:
- redis_data:/data
networks:
- main
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
volumes:
- ./frontend:/code
- /code/node_modules
- /code/.next
networks:
- main
networks:
main:
driver: bridge
volumes:
redis_data:
db logs:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
waiting for server to start....2021-05-18 16:53:49.383 UTC [45] LOG: starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-05-18 16:53:49.387 UTC [45] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-05-18 16:53:49.398 UTC [46] LOG: database system was shut down at 2021-05-18 16:53:49 UTC
2021-05-18 16:53:49.404 UTC [45] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
waiting for server to shut down....2021-05-18 16:53:49.625 UTC [45] LOG: received fast shutdown request
2021-05-18 16:53:49.629 UTC [45] LOG: aborting any active transactions
2021-05-18 16:53:49.630 UTC [45] LOG: background worker "logical replication launcher" (PID 52) exited with exit code 1
2021-05-18 16:53:49.630 UTC [47] LOG: shutting down
2021-05-18 16:53:49.652 UTC [45] LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.
2021-05-18 16:53:49.747 UTC [1] LOG: starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-05-18 16:53:49.748 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-05-18 16:53:49.748 UTC [1] LOG: listening on IPv6 address "::", port 5432
2021-05-18 16:53:49.757 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-05-18 16:53:49.766 UTC [73] LOG: database system was shut down at 2021-05-18 16:53:49 UTC
2021-05-18 16:53:49.772 UTC [1] LOG: database system is ready to accept connections

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'

internal server error while deploying django app

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']