1

While I can run the repo code using python in terminal, So I assume there is no problem in rest.py

While running apache, everything seems to work in apache error.log, Even warnings are generated for flask-sqlalchemy which is supposed to run after executing the .wsgi code.

enter image description here

Error message:

enter image description here

Is there something I am missing? Files and their corresponding code

HDR.conf

<VirtualHost *:4343>
            ServerName http://52.86.97.209/
            ServerAdmin swetabh.pathak@elucidata.io

            WSGIDaemonProcess app python-home=/home/ubuntu/.virtualenvs/venv  user=ubuntu group=ubuntu threads=5
            WSGIScriptAlias / /var/www/hdr_app/HDR.wsgi
            WSGIProcessGroup app
            WSGIApplicationGroup %{GLOBAL}
            <Directory /var/www/hdr_app>
            Require all granted
            </Directory>
            ErrorLog ${APACHE_LOG_DIR}/error.log
            LogLevel debug
            CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


<VirtualHost *:443>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

HDR.wsgi

activate_this = '/home/ubuntu/.virtualenvs/HDR_venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/hdr_app/")

from app import app as application

app.py

from flask_application import app

if __name__ == "__main__":
    app.run(host='0.0.0.0')

Directory Structure for the repo:

hdr_app
|-- app.py
|-- app.pyc
|-- bower.json
|-- contributors.txt
|-- description
|-- flask_application
|   |-- admin
|   |   |-- controllers.py
|   |   `-- __init__.py
|   |-- config.py
|   |-- config.pyc
|   |-- constants.py
|   |-- constants.pyc
|   |-- controllers.py
|   |-- controllers.pyc
|   |-- filters.py
|   |-- filters.pyc
|   |-- helper.py
|   |-- helper.pyc
|   |-- __init__.py
|   |-- __init__.pyc
|   |-- logging_config.py
|   |-- logging_config.pyc
|   |-- public
|   |   |-- controllers.py
|   |   `-- __init__.py
|   |-- res.py
|   |-- rest.py
|   |-- rest.pyc
|   |-- script.py
|   |-- script.pyc
|-- gulpfile.config.js
|-- gulpfile.js
|-- HDR.wsgi
|-- __init__.py
|-- manage.py
|-- package.json
|-- README.md
|-- requirements.txt
  • Not going to cause the problem, but you are missing ``WSGIProcessGroup`` directive. Although you have created a daemon process to run the WSGI application, you haven't actually told mod_wsgi to run it in that process group. – Graham Dumpleton Aug 17 '17 at 04:37
  • Also read http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html as to how to best setup mod_wsgi for a virtual environment. How you do it is not the recommended way. – Graham Dumpleton Aug 17 '17 at 04:38
  • @GrahamDumpleton : Read about the modwsgi doc you mentioned. Tried all the steps, nothing seems to work. – Ankur Panwar Aug 17 '17 at 09:11
  • @GrahamDumpleton : `WSGIProcessGroup app` is also included in .wsgi file. – Ankur Panwar Aug 17 '17 at 09:25
  • It is not meant to be in the ``.wsgi`` file. It is meant to be in the Apache configuration file. Note that ``WSGIProcessGroup`` is not the same as ``WSGIApplicationGroup`` which you added when you edited the question. Its purpose is different, although still recommended to have. – Graham Dumpleton Aug 17 '17 at 09:27
  • Do you have other earlier ``VirtualHost`` definitions in the Apache configuration? The value you have for ``ServerName`` is not usually what you would use. If you have earlier ``VirtualHost`` definitions for same port you are using, the issue probably is that virtual host name matching is failing at it is defaulting to using the first ``VirtualHost`` found. – Graham Dumpleton Aug 17 '17 at 09:29
  • @GrahamDumpleton : I am just using a single enabled conf file. i.e. HDR.conf, nothing else. You are talking about conf files in sites-enabled right ?? – Ankur Panwar Aug 17 '17 at 10:06
  • `WSGIProcessGroup app` is added in .conf file only, that was a typing mistake – Ankur Panwar Aug 17 '17 at 10:38
  • What happens if you add ``app.debug = True`` at end of WSGI script file. Does it cause Flask to return a nicer message in browser. This will confirm that is hitting Flask. – Graham Dumpleton Aug 17 '17 at 11:43
  • Yup `app.debug` was already enabled , The problem was in the code. The rest apis module was not imported in the flask _application. Therefore my app object cannot see those apis – Ankur Panwar Aug 21 '17 at 12:51

0 Answers0