Enable To Initialize Other Python Module Before First Request (django + Mod_wsgi + Apache)
I am pretty new to web applications and recently working on a simple demo system using Django + mod_wsgi. the project looks like this: django/ |- manage.py |- mysite/ |
Solution 1:
Do as Daniel says in the comment and move the code that pre-loads any data into a separate module and invoke it from global scope in the wsgi.py
script file when it is being loaded.
The configuration you are using will pre-load the wsgi.py
when the process is started. You can though simplify the configuration to just:
WSGIDaemonProcess init python-home=/usr/local/.../3.5.0 python-path=/usr/local/.../django
WSGIScriptAlias /myapp /usr/local/.../django/mysite/wsgi.py process-group=init application-group=%{GLOBAL}
<Directory /usr/local/.../django/mysite>
<Fileswsgi.py>
Require all granted
</Files>
</Directory>
Having both the process-group
and application-group
options on the WSGIScriptAlias
directive also triggers force pre-loading of the wsgi.py
script file on process start and you don't need the separate WSGIImportScript
.
Post a Comment for "Enable To Initialize Other Python Module Before First Request (django + Mod_wsgi + Apache)"