简体   繁体   中英

mod_wsgi daemon mode on OS X Server

I've successfully deployed my Django webapp on OS X Server 10.9 using the config .plist and extra httpd.conf using the built-in server manager.

(as per: How does one deploy a django application on OS X Server? , Deploying Django on OS 10.9 Server )

Now I'm trying to get it running using mod_wsgi's daemon mode, rather than the default embedded mode.

So I went back to bare basics: running the included OS X Server mod_wsgi tester bare Python script, which has a httpd conf file with the single line:

WSGIScriptAlias /wsgi /Library/Server/Web/Data/WebApps/hello.wsgi

Changed it to:

WSGIDaemonProcess wsgi_test processes=2 threads=15
WSGIProcessGroup wsgi_test

WSGIScriptAlias /wsgi /Library/Server/Web/Data/WebApps/hello.wsgi

However, it fails when attempting to turn the site back on, with the following message to the apache error log:

[Tue Sep 09 11:56:08 2014] [notice] caught SIGTERM, shutting down
[Tue Sep 09 11:56:12 2014] [crit] (17)File exists: mod_rewrite: Parent could not create RewriteLock file /var/log/apache2/rewrite.lock
Configuration Failed

Then the site 'unticks' itself in the Server admin. I've checked, and the rewrite.lock file doesn't exist when the webserver is turned off.

Should it work? My other concern is whether daemon mode supported out of the box, or I need a new mod_wsgi.

I had a similar error "caught SIGTERM, shutting down" in the Apache error logs on Yosemite. Unfortunately, I can't speak to the mod_rewrite issue.

The SIGTERM seems to occur when the python-path is not set in the WSGIDaemonProcess directive.

Here's a configuration that worked for me for a basic Django app on OSX:

WSGIDaemonProcess myapp processes=2 threads=15 python-path=/path/to/django/app/
WSGIProcessGroup myapp
WSGIScriptAlias /myapp /path/to/django/app/wsgi.py process-group=myapp

<Directory "/path/to/django/app/">
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

I'm not sure if the <Directory> config is required or not. However, setting the python-path in WSGIDaemonProcess solved the SIGTERM issue for me.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM