R
Railway•7mo ago
Beefwater

Deploy Django App - Crashing

Project-ID : bbee3469-8d0f-4c9a-996f-c47676542f62 Preperation: I've searched the discord conversations and have found multiple topics on this issue with those who have had the same issue. You've suggested they create a requirements.txt file and in some other cases indivuduals solved it on their own and didn't include how and in one case an indivicual said redeploying worked fine. In my case, I already have followed the suggested steps. But after everything is deployed, it eventually always crashes. Application Repo: https://github.com/lmayfield78/toilet_train ERRORS:
+0000] [9] [ERROR] Exception in worker process

Traceback (most recent call last):

File "/opt/venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker

worker.init_process()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process

self.load_wsgi()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

self.wsgi = self.app.wsgi()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi

self.callable = self.load()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

return self.load_wsgiapp()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

return util.import_app(self.app_uri)

File "/opt/venv/lib/python3.10/site-packages/gunicorn/util.py", line 371, in import_app

mod = importlib.import_module(module)

File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'toilet_train_project.wsgi'
+0000] [9] [ERROR] Exception in worker process

Traceback (most recent call last):

File "/opt/venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker

worker.init_process()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process

self.load_wsgi()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

self.wsgi = self.app.wsgi()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi

self.callable = self.load()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

return self.load_wsgiapp()

File "/opt/venv/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

return util.import_app(self.app_uri)

File "/opt/venv/lib/python3.10/site-packages/gunicorn/util.py", line 371, in import_app

mod = importlib.import_module(module)

File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1050, in _gcd_import

File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'toilet_train_project.wsgi'
GitHub
GitHub - lmayfield78/toilet_train: The toilets
The toilets. Contribute to lmayfield78/toilet_train development by creating an account on GitHub.
15 Replies
Percy
Percy•7mo ago
Project ID: bbee3469-8d0f-4c9a-996f-c47676542f62
Brody
Brody•7mo ago
folder structure is a bit wrong move every file from the root into the toilet_train_project folder. move everything out of the toilet_train_project folder into the root. remove the quotes from within the procfile
Beefwater
Beefwater•7mo ago
Followed the instructions...I think. Failed faster. I believe I might be missing something from your instructions. Repo: https://github.com/lmayfield78/toilet_train Error:
[Region: us-west1]

==============

Using Nixpacks

==============


context: dbc0b401fe80c62fa008755b9620ab0e

Nixpacks build failed





Nixpacks was unable to generate a build plan for this app.

Please check the documentation for supported languages: https://nixpacks.com



The contents of the app directory are:



settings.py

asgi.py

wsgi.py

__init__.py

__pycache__/

urls.py

toilet_train_project/
[Region: us-west1]

==============

Using Nixpacks

==============


context: dbc0b401fe80c62fa008755b9620ab0e

Nixpacks build failed





Nixpacks was unable to generate a build plan for this app.

Please check the documentation for supported languages: https://nixpacks.com



The contents of the app directory are:



settings.py

asgi.py

wsgi.py

__init__.py

__pycache__/

urls.py

toilet_train_project/
GitHub
GitHub - lmayfield78/toilet_train: The toilets
The toilets. Contribute to lmayfield78/toilet_train development by creating an account on GitHub.
Brody
Brody•7mo ago
bro what happened, this like 10x worse let me know when everything you just did is undone
Beefwater
Beefwater•7mo ago
Everything is reverted. The strange part about Django is when we run the command to startproject, it creates the project file and the sub-project file with the same exact name. So I end up with two files with the same name. And from there it allows us to create the application directory. If the file structure is wrong, I'm wondering if that's a django thing or just what I need to change in order to use Railway. Thanks for the help BTW.
Brody
Brody•7mo ago
dont know why i didnt think of this sooner, just make your structure look like this https://github.com/railwayapp-templates/django
Beefwater
Beefwater•7mo ago
Ok done. I noticed the template didn't have some things I had and did have some things I don't. But I believe this reflects it. https://github.com/lmayfield78/toilet_train Verified - Still crashing with the error ModuleNotFoundError: No module named 'toilet_train_app'
GitHub
GitHub - lmayfield78/toilet_train: The toilets
The toilets. Contribute to lmayfield78/toilet_train development by creating an account on GitHub.
Brody
Brody•7mo ago
still wrong structure, here just replace the contents of your repo with the contents of this zip https://test-service1.up.railway.app/
Beefwater
Beefwater•7mo ago
Thank you for fixing this for me. I appreciate your help. I have a request. If anyone comes after me and searches through the conversations and comes across this one, would you be able to walk me through what I did wrong? I followed the steps of the Django documentation. The structure was as they specified and the app ran locally. You knew exactly what was wrong and how to fix it. Is that documented somewhere? Or are there any references you can point me to to bookmark/study so I can learn to problem solve myself? I'd really like to know how or where I need to learn what you already knew. Thanks for your assistance.
Brody
Brody•7mo ago
funny enough ive never even worked on a django app for myself, and im not even a python dev this is what i used for reference on how to get your app up and running, thats all i did, make yours look like this one
Beefwater
Beefwater•7mo ago
Ah ok. I did notice your version had an additional .json file. I know you said you just reflected the directory structure, but was there anything you immediately knew was wrong based on knowledge? I'm learning that theres a difference of how to build a Django app vs deploying a Django app in railway In any case, you helped me out a ton. Thanks.
Brody
Brody•7mo ago
I simply just looked at railways template for django, and looked at yours, made them the same and it worked, you're definitely over thinking this looked at the structure of the template, made yours the same. looked at the settings.py from the template, made yours the same. looked at the start command of the template (railway.json), made yours the same. etc. etc.
Beefwater
Beefwater•7mo ago
Ah, got it. Thanks again.
Brody
Brody•7mo ago
no problem 🙂