phusion / passenger

A fast and robust web server and application server for Ruby, Python and Node.js
https://www.phusionpassenger.com/
MIT License
5k stars 547 forks source link

Django application not running, wsgi error? #2206

Open HCARLS opened 5 years ago

HCARLS commented 5 years ago

I´m using django 2.2 and Python 3.6, i can´t understand this error log, i´m rookie, it´s my first application, I´m hopeless, on localhost work fine. Thank you.

Traceback (most recent call last):
  File "/opt/passenger-5.3.7-3.el7.cloudlinux/src/helper-scripts/wsgi-loader.py", line 369, in <module>
    app_module = load_app()
  File "/opt/passenger-5.3.7-3.el7.cloudlinux/src/helper-scripts/wsgi-loader.py", line 76, in load_app
    return imp.load_source('passenger_wsgi', startup_file)
  File "/home/user/virtualenv/my_app/3.6/lib64/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/my_app/passenger_wsgi.py", line 8, in <module>
    wsgi = imp.load_source('wsgi', 'wsgi.py')
  File "/home/user/virtualenv/my_app/3.6/lib64/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "wsgi.py", line 8, in <module>
    wsgi = imp.load_source('wsgi', 'passenger_wsgi.py')
  File "/home/user/virtualenv/my_app/3.6/lib64/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "passenger_wsgi.py", line 8, in <module>
    wsgi = imp.load_source('wsgi', 'wsgi.py')

Modules:

astroid | 2.2.5 | [x]
certifi | 2019.3.9 | [x]
colorama | 0.4.1 | [x]
cymysql | 0.9.13 | [x]
Django | 2.2 | [x]
django-cymysql | 2.2.0 | [x]
isort | 4.3.20 | [x]
lazy-object-proxy | 1.4.1 | [x]
mccabe | 0.6.1 | [x]
mysql-connector-python | 8.0.16 | [x]
mysqlclient | 1.4.2 | [x]
Pillow | 6.0.0 | [x]
protobuf | 3.7.1 | [x]
pylint | 2.3.1 | [x]
pylint-django | 2.0.9 | [x]
pylint-plugin-utils | 0.5 | [x]
PyMySQL | 0.9.3 | [x]
pytz | 2019.1 | [x]
six | 1.12.0 | [x]
sqlparse | 0.3.0 | [x]
typed-ast | 1.3.5 | [x]
wheel | 0.29.0 | [x]
wincertstore | 0.2 | [x]
wrapt | 1.11.1 | [x]

Error Cpanel:

[ E 2019-05-22 13:21:26.9079 18167/Tr age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/user/my_app: The application process exited prematurely.
App 28425 output:   File "/home/user/virtualenv/my_app/3.6/lib64/python3.6/imp.py", line 170, in load_source
App 28425 output:   File "/home/user/virtualenv/my_app/3.6/lib64/python3.6/imp.py", line 170, in load_source
CamJN commented 5 years ago

It looks like the actual error message got lost. Passenger's wsgi loader tries to load your app, and fails but as to why? That's not included in the logs you've provided.

If i had to guess, I'd wonder if the virtualenv that you're using, does it have binaries appropriate for cloudlinux? For eg. if you setup the virtualenv on windows/macOS and installed the deps there (or compiled cython modules) and just copied the virtualenv over to the server as-is then any binaries will be incompatible with the server OS.

You can try increasing the passenger log level to 7 to get more logs and hopefully capture the actual error message.

iDineshRoy commented 3 years ago

For me fixing up the passenger_wsgi.py fixed it. I removed everything in it and put:

from appname.wsgi import application