General suggestions already given have been in the right direction. Some links 
for reading related to Python virtual environments and use of multiple daemon 
process groups can be found at:

* 
http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html 
<http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html>
* http://blog.dscpl.com.au/2014/02/vertically-partitioning-python-web.html 
<http://blog.dscpl.com.au/2014/02/vertically-partitioning-python-web.html>
* http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html 
<http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html>

BTW, Jason, have you ever gone and looked at all the new timeout options 
available for daemon mode to help automatically deal with an application which 
has hung up or blocked on backend services.

See:

* 
http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html
 
<http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html>

New options which most people wouldn't know about are:

* restart-interval=nnn
* request-timeout=sss
* startup-timeout=sss
* queue-timeout=sss
* graceful-timeout=sss

The behaviour of these options also change in 3.0+.

* inactivity-timeout=sss

Using these timeout options can help with making things more stable and able to 
automatically recover from certain situations.

Because of history, many aren't enabled by default if manually configuring 
mod_wsgi. In mod_wsgi-express various of these are on by default with some 
reasonable defaults.

Graham

> On 6 May 2017, at 3:22 AM, Jason Garber <[email protected]> wrote:
> 
> This might be helpful.  A little overview.
> 
> We run nginx in front of apache.  This accomplishes two or three things:
> 
> 1. all static assets are served via nginx - super fast.  Anything with an 
> extension is served directly by nginx.
> 2. ssl termination is done in nginx, which is also very speedy and super easy 
> to configure.
> 3. we have free load balancing if we choose to utilize it by adding more 
> apache back ends.
> 
> We also have done away with crontabs and use a background process (with 
> spawned threads - one per type of task).  This is managed by mod_wsgi and 
> runs under apache as a separate process.
> 
> Lastly note that, in our case, if it makes it to apache it is destined for 
> mod_wsgi, which is why we have configured it this way.  
> 
> Regarding python path, you need options to WSGIDaemonProcess (see below).  It 
> works perfectly.
> 
> 
> Global apache conf
> 
> <IfModule !wsgi_module>
>     LoadModule wsgi_module modules/mod_wsgi_python3.5.so 
> <http://mod_wsgi_python3.5.so/>
>     WSGISocketPrefix run/wsgi
>     WSGIApplicationGroup %{GLOBAL}
> </IfModule>
> 
> # Background Processing
> 
> One project's background processor
> 
> Listen 127.0.0.1:60810 <http://127.0.0.1:60810/>
> 
> <VirtualHost 127.0.0.1:60810 <http://127.0.0.1:60810/>>
>   ServerName _default_;
>   WSGIDaemonProcess async-60810 processes=1 threads=1 
> python-path=/home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Python 
> display-name=async-60810
>   WSGIImportScript 
> /home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Async/wsgi_import_script.wsgi
>  process-group=async-60810 application-group=%{GLOBAL}
> 
>   ErrorLog 
> /home/jason/DevLevel.2/DaaS-Installation/DaaS/Run/Hub.httpd-error.log
> 
> </VirtualHost>
> 
> 
> One project's website
> 
> WSGIDaemonProcess Port60811 processes=2 threads=1 
> python-path=/home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Python
> Listen 127.0.0.1:60811 <http://127.0.0.1:60811/>
> NameVirtualHost 127.0.0.1:60811 <http://127.0.0.1:60811/>
> 
> <VirtualHost 127.0.0.1:60811 <http://127.0.0.1:60811/>>
>   ServerName _default_
>   DocumentRoot /home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Web/Main
>   AddDefaultCharset UTF-8
> 
>   RewriteEngine on
>   RewriteOptions inherit
> 
>   # Forbid any python source files from being served.
>   RewriteRule \.(py|pyc|pyo|wsgi)$  -  [F]
> 
>   WSGIScriptAlias / 
> /home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Web/Main/__init__.wsgi
>   WSGIProcessGroup Port60811
> 
>   LogLevel info
>   ErrorLog 
> /home/jason/DevLevel.2/DaaS-Installation/DaaS/Run/Hub.httpd-error.log
> </VirtualHost>
> 
> 
> ---------------------------------------
> 
> We use nginx in front of it - highly recommend it
> 
> server
> {
>   listen 192.168.50.12:80 <http://192.168.50.12/>;
>   listen 192.168.50.12:443 <http://192.168.50.12:443/> ssl;
>   server_name admin--daashub--com--jason.step.appcove.net 
> <http://admin--daashub--com--jason.step.appcove.net/>;
> 
> 
>   ssl_certificate     ssl/WILDCARD.step.appcove.net.crt;
>   ssl_certificate_key ssl/WILDCARD.step.appcove.net.key;
> 
>   proxy_set_header Host $host;
>   proxy_set_header X-Real-IP $remote_addr;
>   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>   proxy_set_header Scheme $scheme;
> 
>   client_max_body_size 1000m;
> 
>   location ~ \.(py|pyc|pyo|wsgi)$
>   {
>     return 403;
>   }
> 
>   location ~ \.([a-zA-Z0-9])+$
>   {
>     root  /home/jason/DevLevel.2/DaaS-Installation/DaaS/Hub/Web/Main;
>     expires max;
>   }
> 
>   location /
>   {
>     add_header Cache-Control 'no-cache, no-store, max-age=0, must-revalidate';
>     add_header Expires 'Thu, 01 Jan 1970 00:00:01 GMT';
>     proxy_pass http://127.0.0.1:60811 <http://127.0.0.1:60811/>;
>   }
> }
> 
> 
> 
> 
> On Fri, May 5, 2017 at 11:38 AM, Bill Freeman <[email protected] 
> <mailto:[email protected]>> wrote:
> See the python-home argument to WSGIDaemonProcess
> 
> PYTHON_HOME is per process, so you must use daemon processes and have 
> separate processes/groups for apps requiring separate virtualenvs.
> 
> On Fri, May 5, 2017 at 11:30 AM, Jared Greenwald <[email protected] 
> <mailto:[email protected]>> wrote:
> We're finally converting our project from mod_python to mod_wsgi and I'm 
> running into an issue with converting our apache config - hoping someone can 
> provide guidance.
> 
> We have our environment setup such that we have multiple versions of the same 
> application (testing & production) running on the same machine but accessed 
> via different ports.  These ports map to different VitualHost configurations 
> which had different PythonPath directives set so that we could set different 
> code stacks for rolling out the different versions of our app to testing and 
> then to production.  The issue I'm seeing now is that the WSGIPythonPath 
> directive which would seem to be the analogous directive to the mod_python 
> PythonPath directive doesn't allow for it to be set within a VirtualHost.  
> Obviously, I can't just set the path globally for all VirtualHosts since I 
> have two completely separate code directories for each of the two 
> environments.
> 
> So, the question is, how do I setup my apache config to allow for this type 
> of setup?  I've tried to Googling around for an answer on this before coming 
> here but I haven't been able to come up with a good solution.  Any help would 
> be much appreciated.
> 
> Thanks in advance.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to