Setting Up CodeDeploy to EC2 for Tutor

Hello AWS users,

Has anyone set up a AWS CodeDeploy for tutor? I have the whole CodePipeline + CodeDeploy to EC2 (process starts when there is a Github action to the repo) where during the ApplicationStart hook, CodeDeploy runs a script that has the following line tutor local start -d.

When the tutor is successfully deployed using the whole pipeline and I navigate to either LMS or CMS I receive a 500 error. I checked the docker containers and none of them seem to have any issue. It isn’t until I manually enter the command tutor local start -d again does the nginx issue go away.

Has anyone encountered this issue and if so how did you fix it?

Here’s the following log for nginx

Attaching to tutor_local_nginx_1
nginx_1             | 172.105.89.161 - - [07/Dec/2020:17:12:58 +0000] http://cms-dev.linggoapi.com "GET /0bef HTTP/1.0" 400 26 "-" "-" "-"
nginx_1             | 173.0.57.195 - - [07/Dec/2020:17:42:48 +0000] http://cms-dev.linggoapi.com "\x16\x03\x01\x00u\x01\x00\x00q\x03\x03\xD7\x12\x0C{+\x08\x0C" 400 166 "-" "-" "-"
nginx_1             | 34.228.64.137 - - [07/Dec/2020:18:13:44 +0000] http://3.238.247.241 "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) Project-Resonance (http://project-resonance.com/) (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" "-"
nginx_1             | 142.126.119.203 - - [07/Dec/2020:18:27:14 +0000] http://lms-dev.linggoapi.com "GET /admin/login/?next=/admin/ HTTP/1.1" 500 141 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"
nginx_1             | 142.126.119.203 - - [07/Dec/2020:18:39:20 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"
nginx_1             | 34.228.199.107 - - [07/Dec/2020:18:39:40 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)" "-"
nginx_1             | 34.228.199.107 - - [07/Dec/2020:18:39:40 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:41:23 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:41:24 +0000] http://lms-dev.linggoapi.com "GET /favicon.ico HTTP/1.1" 200 30237 "http://lms-dev.linggoapi.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:41:42 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:43:31 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:43:31 +0000] http://lms-dev.linggoapi.com "GET /favicon.ico HTTP/1.1" 200 30237 "http://lms-dev.linggoapi.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 139.162.119.197 - - [07/Dec/2020:18:43:47 +0000] http://3.238.247.241 "GET / HTTP/1.1" 400 37 "-" "HTTP Banner Detection (https://security.ipip.net)" "-"
nginx_1             | 174.91.159.30 - - [07/Dec/2020:18:49:12 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0" "-"
nginx_1             | 142.126.119.203 - - [07/Dec/2020:18:49:29 +0000] http://lms-dev.linggoapi.com "GET / HTTP/1.1" 500 141 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" "-"

LMS Log

lms_1               | Traceback (most recent call last):
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 34, in inner
lms_1               |     response = get_response(request)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/whitenoise/middleware.py", line 58, in __call__
lms_1               |     response = self.get_response(request)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 36, in inner
lms_1               |     response = response_for_exception(request, exc)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
lms_1               |     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 129, in handle_uncaught_exception
lms_1               |     return callback(request, **param_dict)
lms_1               |   File "/openedx/edx-platform/common/djangoapps/util/views.py", line 98, in wrapper
lms_1               |     return func(request, *args, **kwargs)
lms_1               |   File "/openedx/edx-platform/lms/djangoapps/static_template_view/views.py", line 103, in render_500
lms_1               |     return HttpResponseServerError(render_to_string('static_templates/server-error.html', {}, request=request))
lms_1               |   File "/openedx/edx-platform/common/djangoapps/edxmako/shortcuts.py", line 177, in render_to_string
lms_1               |     return template.render(dictionary, request)
lms_1               |   File "/openedx/edx-platform/common/djangoapps/edxmako/template.py", line 83, in render
lms_1               |     return self.mako_template.render_unicode(**context_dictionary)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/template.py", line 454, in render_unicode
lms_1               |     as_unicode=True)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/runtime.py", line 829, in _render
lms_1               |     **_kwargs_for_callable(callable_, data))
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/runtime.py", line 864, in _render_context
lms_1               |     _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/runtime.py", line 890, in _exec_template
lms_1               |     callable_(context, *args, **kwargs)
lms_1               |   File "/tmp/mako_lms/ac16784d5a7c7e5647770588ca0dc619/main.html.py", line 339, in render_body
lms_1               |     runtime._include_file(context, (static.get_template_path('header.html')), _template_uri, online_help_token=online_help_token)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/runtime.py", line 752, in _include_file
lms_1               |     callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
lms_1               |   File "/tmp/mako_lms/ac16784d5a7c7e5647770588ca0dc619/header.html.py", line 34, in render_body
lms_1               |     runtime._include_file(context, (static.get_template_path(relative_path='header/header.html')), _template_uri, online_help_token=online_help_token)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/mako/runtime.py", line 752, in _include_file
lms_1               |     callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
lms_1               |   File "/tmp/mako_lms/ac16784d5a7c7e5647770588ca0dc619/header/header.html.py", line 88, in render_body
lms_1               |     if waffle.switch_is_active('enable_unsupported_browser_alert'):
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/waffle/__init__.py", line 21, in switch_is_active
lms_1               |     switch = Switch.get(switch_name)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/waffle/models.py", line 51, in get
lms_1               |     obj = cls.get_from_db(name)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/waffle/models.py", line 64, in get_from_db
lms_1               |     return objects.get(name=name)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method
lms_1               |     return getattr(self.get_queryset(), name)(*args, **kwargs)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/query.py", line 402, in get
lms_1               |     num = len(clone)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/query.py", line 256, in __len__
lms_1               |     self._fetch_all()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/query.py", line 1242, in _fetch_all
lms_1               |     self._result_cache = list(self._iterable_class(self))
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/query.py", line 55, in __iter__
lms_1               |     results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1138, in execute_sql
lms_1               |     cursor = self.connection.cursor()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 256, in cursor
lms_1               |     return self._cursor()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 233, in _cursor
lms_1               |     self.ensure_connection()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
lms_1               |     self.connect()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
lms_1               |     raise dj_exc_value.with_traceback(traceback) from exc_value
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
lms_1               |     self.connect()
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 195, in connect
lms_1               |     self.connection = self.get_new_connection(conn_params)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
lms_1               |     return Database.connect(**conn_params)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/MySQLdb/__init__.py", line 84, in Connect
lms_1               |     return Connection(*args, **kwargs)
lms_1               |   File "/openedx/venv/lib/python3.5/site-packages/MySQLdb/connections.py", line 179, in __init__
lms_1               |     super(Connection, self).__init__(*args, **kwargs2)
lms_1               | django.db.utils.OperationalError: (1045, "Access denied for user 'openedx'@'172.24.0.9' (using password: YES)")