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>
<Files wsgi.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
.
Source:stackexchange.com