0
votes

I have problem when developing in Python Bottle on Apache. Each time I change file dbmanager.py that I import to main app.wsgi, nothing change. I need to "touch" app.wsgi to see changes in dbmanager.py or restart apache. I tried everything: changes in .htaccess, apache Virtual Host config. But still nothnig. Any ideas?

Path to my files is:

/var/www/paka/public_html/edi/api/app.wsgi

I have two files:

app.wsgi

import os, sys
from os.path import dirname
sys.path.append(dirname(__file__))

import bottle
from bottle import route, run, template, post, request, response
bottle.debug(True)
bottle.TEMPLATES.clear()

import dbmanager
c = dbmanager.connect()

@route('/hello/<name>')
def index(name):
    #return hello.world()  # only log in console
    return template('<b>Hello  {{name}}</b>!' + c, name=name)

application = bottle.default_app()

and dbmanager.py

import mysql, mysql.connector

def connect():
    return "123456"

My .htaccess

# DISABLE CACHING
ExpiresActive On
ExpiresDefault A1
Header append Cache-Control must-revalidate

<IfModule mod_headers.c>
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires 0
</IfModule>

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|png|pdf|swf|txt|py|pcc)$">
        <IfModule mod_expires.c>
                ExpiresActive Off
        </IfModule>
        <IfModule mod_headers.c>
                FileETag None
                Header unset ETag
                Header unset Pragma
                Header unset Cache-Control
                Header unset Last-Modified
                Header set Pragma "no-cache"
                Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
                Header set Expires "Mon, 10 Apr 1972 00:00:00 GMT"
        </IfModule>
</FilesMatch>

My VirtualHost config:

WSGIDaemonProcess bottle user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias / /var/www/paka/public_html/edi/api/app.wsgi

<Directory /var/www/paka/public_html/edi/api/>
    WSGIProcessGroup bottle
    WSGIApplicationGroup %{GLOBAL}
    Require all granted
</Directory>
1
After the file changes try restart apache ? - Raja Simon
Yes, when I restart apache I see changes. So there is no other options? I always need to restart jeeves after modify file? - user3345547

1 Answers

0
votes

The topic of source code reloading is covered in detail in the mod_wsgi documentation.

You either have to touch the WSGI script file, or if this is a development system, you can add some code to the WSGI script as documented, which will detect changes and auto restart processes.

Better still, for development, use mod_wsgi-express and use the --reload-on-changes option.

There is too much detail in the documentation on this topic to wholesale cut and paste here.