0

I'm experimenting with developing python flask app, and would like to configure the app to apache as a daemon, so I wouldn't need to restart apache after every change. The configuration is now like instructed here:

httpd.conf

WSGIDaemonProcess /rapo threads=5 display-name=%{GROUP}
WSGIProcessGroup /rapo
WSGIScriptAlias /rapo /var/www/cgi-bin/pycgi/koe.wsgi

koe.wsgi contains just

import sys
sys.path.insert(0, "/var/www/cgi-bin/pycgi")
from koe2 import app as application

And in koe2.py there is

@app.route('/rapo')
def hello_world():
   return 'Hello, World!'

that output I can see when I go to the webserver's /rapo/hello -path, so flask works, but the daemon configuration does not (I still need to restart to see any changes made). Here with similar problem it seems the key was that the names match, and they do. SW versions: Apache/2.4.6 (CentOS) PHP/5.4.16 mod_wsgi/3.4.

We don't have any virtual hosts defined in the httpd.conf, which might be the missing thing, as that worked in this case? Thanks for any help!

Tuula
  • 176
  • 2
  • 10

2 Answers2

0

Would this modification to your httpd.conf file help?

WSGIDaemonProcess api threads=5
WSGIScriptAlias /rapo /var/www/cgi-bin/pycgi/koe.wsgi

<Directory rapo>
    WSGIProcessGroup rapo
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>
Mika72
  • 413
  • 2
  • 12
  • Thanks, tried, restarted apache and went to my app via browser. Error log just gives error " No WSGI daemon process called 'rapo' has been configured: /var/www/cgi-bin/pycgi/koe.wsgi" . (tried also by replacing 'api' with 'rapo' and with path – Tuula May 07 '18 at 07:50
  • Here's instructions, I have followed: http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/ – Mika72 May 07 '18 at 08:09
  • The example should have used ``WSGIProcessGroup api`` not ``WSGIProcessGroup rapo``, but the result would have been the same as was originally used. – Graham Dumpleton May 07 '18 at 16:50
0

Python is not like PHP, source code changes are not reloaded automatically on the next request. In the case of daemon mode, you still need to at least touch the WSGI script file. You can find details about how reloading is handled in:

At the end of the doc you will find a way of adding code to your application to have source code automatically reloaded no matter what code file is changed, but that should only be done for development and not in production.

If doing development, you are better off using mod_wsgi-express from the command line. When you do that, you can use the --reload-on-changes option to enable reload on any changes. See:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134