dedepene
dedepene

Reputation: 23

Errors crash the local development django cookie-cutter container

I've setup Django cookie-cutter for local development in Docker. It all works fine, even with VSCode devcontainer, changes are tracked and reloaded until there's a syntax or some other error. Then the entire container exits with code 1, which launches a cascade of errors in other containers that manage to stay alive while the django container remains dead :(

It's all pretty much a generic django cookie cutter install with a few changes like:

exec python manage.py runserver_plus --reloader-interval 3 --reloader-type stat 0.0.0.0:8000

Werkzeug==3.0.3

Any hints how to reload changes, log errors but keep the container and server alive?

Here's the container log for reference:

2024-07-10 13:57:55 Operations to perform:
2024-07-10 13:57:55   Apply all migrations: account, admin, auth, contenttypes, django_celery_beat, mfa, sessions, sites, socialaccount, users
2024-07-10 13:57:55 Running migrations:
2024-07-10 13:57:55   No migrations to apply.
2024-07-10 13:57:55   Your models in app(s): 'core' have changes that are not yet reflected in a migration, and so won't be applied.
2024-07-10 13:57:55   Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
2024-07-10 13:58:01 Performing system checks...
2024-07-10 13:58:01 
2024-07-10 13:58:01 System check identified no issues (0 silenced).
2024-07-10 13:58:01 
2024-07-10 13:58:01 Django version 4.2.13, using settings 'config.settings.local'
2024-07-10 13:58:01 Development server is running at http://0.0.0.0:8000/
2024-07-10 13:58:01 Using the Werkzeug debugger (https://werkzeug.palletsprojects.com/)
2024-07-10 13:58:01 Quit the server with CONTROL-C.
2024-07-10 13:57:42 PostgreSQL is available
2024-07-10 13:57:42 /start: line 1: local: can only be used in a function
2024-07-10 13:57:59 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
2024-07-10 13:57:59  * Running on all addresses (0.0.0.0)
2024-07-10 13:57:59  * Running on http://127.0.0.1:8000
2024-07-10 13:57:59  * Running on http://172.18.0.7:8000
2024-07-10 13:57:59 Press CTRL+C to quit
2024-07-10 13:57:59  * Restarting with stat
2024-07-10 13:58:02  * Debugger is active!
2024-07-10 13:58:02  * Debugger PIN: 146-133-257
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /test HTTP/1.1" 200 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/css/project.css HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/debug_toolbar/css/print.css HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/js/project.js HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 304 -
2024-07-10 13:58:37 172.18.0.1 - - [10/Jul/2024 13:58:37] "GET /static/images/favicons/favicon.ico HTTP/1.1" 304 -
2024-07-10 13:58:50  * Detected change in '/app/core/templates/core/idx.html', reset template loaders
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /test HTTP/1.1" 200 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/debug_toolbar/css/print.css HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/css/project.css HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/js/project.js HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 304 -
2024-07-10 13:59:03 172.18.0.1 - - [10/Jul/2024 13:59:03] "GET /static/images/favicons/favicon.ico HTTP/1.1" 304 -
2024-07-10 13:59:27  * Detected change in '/app/core/models.py', reloading
2024-07-10 13:59:27  * Restarting with stat
2024-07-10 13:59:31 Traceback (most recent call last):
2024-07-10 13:59:31   File "/app/manage.py", line 32, in <module>
2024-07-10 13:59:31     execute_from_command_line(sys.argv)
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
2024-07-10 13:59:31     utility.execute()
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
2024-07-10 13:59:31     django.setup()
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
2024-07-10 13:59:31     apps.populate(settings.INSTALLED_APPS)
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/site-packages/django/apps/registry.py", line 116, in populate
2024-07-10 13:59:31     app_config.import_models()
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/site-packages/django/apps/config.py", line 269, in import_models
2024-07-10 13:59:31     self.models_module = import_module(models_module_name)
2024-07-10 13:59:31                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-10 13:59:31   File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-07-10 13:59:31     return _bootstrap._gcd_import(name[level:], package, level)
2024-07-10 13:59:31            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-10 13:59:31   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-07-10 13:59:31   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-07-10 13:59:31   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2024-07-10 13:59:31   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2024-07-10 13:59:31   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
2024-07-10 13:59:31   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-07-10 13:59:31   File "/app/core/models.py", line 8, in <module>
2024-07-10 13:59:31     dksfj
2024-07-10 13:59:31 NameError: name 'dksfj' is not defined

Upvotes: 0

Views: 45

Answers (0)

Related Questions