Source code change not taken into account

18 views
Skip to first unread message

Anthony Sanchez

unread,
Feb 21, 2024, 5:47:52 AMFeb 21
to modwsgi
Hi all,

I am facing a small issue regarding the reload of my source code change with mod_wsgi in embeded mode.
I made some changes in my code source, but those changes are not taken into account when I restart apache. I did the following with no result :
  • applied a minor change in the wsgi entry file ;
  • restarted the apache server.
But nothing happened. I checked apache logs and all I see is normal activity. What am I missing ?
My configurations below :

wsgi entry file :
import sys
path = '/var/www/mysite.fr/.venv_vo2/lib/python3.11/sites-packages'
if path not in sys.path:
    sys.path.insert(0, path)

from mysite import create_app
application = create_app()
-----------------------------------------------------------------------------------------------------------------------------
my virtualhost conf file :
<VirtualHost *:80>
    ServerName mysite.fr
    ServerAlias www.mysite.fr

    DocumentRoot /var/www/mysite.fr/mysite/

    WSGIScriptAlias / /var/www/mysite.fr/mysite/mysite.wsgi
    WSGIScriptReloading On
    WSGIApplicationGroup %{GLOBAL}
   
    <Directory /var/www/mysite.fr/mysite/>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mysite.fr [OR]
RewriteCond %{SERVER_NAME} =www.mysite.fr
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

-----------------------------------------------------------------------------------------------------------
virtual host conf encrypted version :
<IfModule mod_ssl.c>
<VirtualHost *:443>
 [...]
    DocumentRoot /var/www/mysite.fr/mysite/
   
    WSGIScriptAlias / /var/www/mysite.fr/mysite/mysite.wsgi
    WSGIScriptReloading On

[...]
</VirtualHost>
</IfModule>


Many Thanks,
Anthony

Anthony Sanchez

unread,
Feb 21, 2024, 6:05:40 AMFeb 21
to modwsgi
Solved the issue. I just had to reorganise my wsgi entry file like this :
import sys
path = '/var/www/mysite.fr/mysite'

if path not in sys.path:
    sys.path.insert(0, path)

from app import create_app
application = create_app()

with app.py located within the same directory as the wsgi entry file ; I also changed my virtual host conf to include the virtual env as per the documentation.

Thanks again.
Reply all
Reply to author
Forward
0 new messages