Obvious really. :-)
The code:
if not os.environ.get('mod_wsgi.process_group'):
output = 'EMBEDDED MODE'
else:
output = 'DAEMON MODE'
is wrong. It should be either:
import mod_wsgi
if not mod_wsgi.process_group:
output = 'EMBEDDED MODE'
else:
output = 'DAEMON MODE'
or:
def application(environ, start_response):
status = '200 OK'
if not environ['mod_wsgi.process_group']:
output = u'EMBEDDED MODE'
else:
output = u'DAEMON MODE'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output.encode('UTF-8')]
It is not an environment variable in the latter, so not 'os.environ', but the
value from the environ argument to the application.
The first method picks it up direct from the 'mod_wsgi' module and so can be
used at global scope.
Graham
> On 15 Feb 2019, at 2:23 pm, 阿尼 <[email protected]> wrote:
>
> Okay.
> I did not get errors when I restart Apache after adding WSGIRestrictEmbedded
> On.
> Apache failed after I add an invalid line in the configuration.
>
> I also changed the LogLevel to info but it seems to be normal, unless these
> messages are related:
> [Fri Feb 15 10:22:45.683121 2019] [auth_digest:notice] [pid 1441] AH01757:
> generating secret for digest authentication ...
> [Fri Feb 15 10:22:45.683873 2019] [lbmethod_heartbeat:notice] [pid 1441]
> AH02282: No slotmem from mod_heartmonitor
>
>
>
>
>
>
>
> Graham Dumpleton於 2019年2月15日星期五 UTC+8上午5時31分39秒寫道:
> When you added:
>
> WSGIRestrictEmbedded On
>
> and restarted Apache, did you then get errors?
>
> If that directive is in the correct place, it cannot use embedded mode. If it
> still is, it suggests the configuration isn't even been run.
>
> Suggest added some invalid configuration at same place and restart Apache and
> see if Apache even fails to start. That will confirm whether it is being
> read. Invalid configuration can be:
>
> XXX
>
> on a line by itself. Apache should fail on that.
>
> Also ensure using:
>
> LogLevel info
>
> rather than LogLevel of warn or err. The use of 'info' will cause mod_wsgi to
> output log messages about restarts, daemon group and interpreter used. This
> will help in debugging what is happening.
>
> Graham
>
>> On 14 Feb 2019, at 5:57 pm, 阿尼 <afji...@ <>gmail.com <http://gmail.com/>>
>> wrote:
>>
>> 'myip' is just a thing to substitute the real IP address I used, did not
>> think of using a star: *. lol
>> and 'myproject' is my fault either, it is different Unicode characters but
>> only in this post.
>>
>> I said that I am not in daemon mode is because I followed the document
>> <https://modwsgi.readthedocs.io/en/develop/user-guides/reloading-source-code.html#embedded-mode-vs-daemon-mode>
>> to add the code in my wsgi.py:
>> if not os.environ.get('mod_wsgi.process_group'):
>> output = 'EMBEDDED MODE'
>> else:
>> output = 'DAEMON MODE'
>>
>>
>> It prints out 'EMBEDDED MODE' and I do need to reload Apache everytime I
>> changed my source code.
>> Even if I add WSGIRestrictEmbedded On, it still can work but still prints
>> out 'EMBEDDED MODE'.
>>
>> I am hosting other PHP applications at the same Apache Server, not knowing
>> if it concerns.
>>
>>
>> 阿尼於 2019年2月13日星期三 UTC+8上午11時51分26秒寫道:
>> Hello
>>
>> I have set my configuration like following, but it seems I am not into the
>> deamon mode.
>> did I miss something?
>> <VirtualHost myip>
>> ServerName myname
>> CustomLog /var/log/httpd/myname-access.log common
>> ErrorLog /var/log/httpd/myname-error.log
>>
>> WSGIDaemonProcess myproject python-home=/path/to/myproject/.env
>> WSGIProcessGroup myproject
>> WSGIScriptAlias / '/path/to/myproject/myproject/wsgi.py'
>> <Directory '/path/to/myproject/myproject'>
>> <Files wsgi.py>
>> Require all granted
>> </Files>
>> </Directory>
>>
>> Alias '/static' '/homepage/myproject/static-files'
>> <Directory '/homepage/myproject/static-files'>
>> AllowOverride None
>> Require all granted
>> </Directory>
>> </VirtualHost>
>>
>>
>>
>>
>> --
>> 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 modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>.
>> To post to this group, send email to mod...@ <>googlegroups.com
>> <http://googlegroups.com/>.
>> 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.