> On 17 Dec 2018, at 4:51 pm, [email protected] wrote:
>
> Thanks, Graham! I swear I tried a variation on what you're suggesting, but
> I've just given it another go and have gotten the application logging working
> now, thanks!!
>
> I did end up getting mod_wsgi-express working, but it was right fiddly to do,
> and would need a whole new suite of performance/memory/load testing, so I'm
> going to stick with the existing configuration for now.
>
> I did notice as I was poking around that I'm getting this in the output
> (seems to be direct to stderr or stdout) when a mod_wsgi process handles its
> first request:
>
> { "time":"Mon Dec 17 15:57:36 2018", "function" : "[wsgi:info]" , "message" :
> "mod_wsgi (pid=12, process='', application='172.17.0.2:8000|'): Loading
> Python script file '/app/main/wsgi.py'.", "referer" : "-" }
> {"asctime": "2018-12-17 15:57:37,498", "levelname": "INFO", "message": "New
> Relic Python Agent (4.4.1.104)"}
> {"asctime": "2018-12-17 15:57:37,788", "levelname": "INFO", "message": "INFO
> MESSAGE"}
> {"asctime": "2018-12-17 15:57:37,788", "levelname": "ERROR", "message":
> "ERROR MESSAGE"}
> File "setup.py", line 38
> f.write(f'version = "{version}"\n')
> ^
> SyntaxError: invalid syntax
I am an old guy who doesn't learn new tricks. I have never used f-strings, but
that is more to do with needing to support old Python versions. So I am not
quite sure where that might be coming from. It is definitely not mod_wsgi. Try
doing a 'find / -name setup.py' and see if you can find where the file might
be. If it is a transient file due to something trying to install something on
demand, you might not catch where it is though.
> { "time":"Mon Dec 17 15:57:38 2018", "function" : "[deflate:debug]" ,
> "message" : "AH01384: Zlib: Compressed 29570 to 4102 : URL /trs-menu/menu/",
> "referer" : "-" }
> { "time":"2018-12-17T15:57:36.366Z", "request":"/trs-menu/menu/", "query":"",
> "method":"GET", "status":"200" }
>
> That looks like what you get if you try to hand source with an f-string in it
> to Python 2.7...
> I installed mod_wsgi with Python 3.6, though Python 2.7 is installed in the
> image too (as a dependency of the node.js programming language deb, no
> kidding).
> The application runs fine though (it's definitely a Python 3.6+ application
> too).
>
>
> On Monday, December 17, 2018 at 3:55:13 PM UTC+11, Graham Dumpleton wrote:
> Lets solve your Django logging issue and put aside the issue of moving to
> mod_wsgi-express for now.
>
> For a process other that PID 1 to log director the container stdout/stderr,
> it can use:
>
> /proc/1/fd/1
> /proc/1/fd/2
>
> Your Django logging configuration, to have it avoid the Apache error logging
> mechanism would thus be something like:
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'handlers': {
> 'file': {
> 'class': 'logging.FileHandler',
> 'filename': '/proc/1/fd/1',
> },
> },
> 'loggers': {
> 'django': {
> 'handlers': ['file'],
> 'level': 'INFO',
> },
> },
> }
>
> So get that working with your existing images. We can then see later whether
> is worthwhile looking at mod_wsgi-express.
>
> What you might at least get out of mod_wsgi-express is some hints as to
> possible better configuration for working in a container. This is because
> mod_wsgi-express generates a complete Apache configuration for you. You don't
> just point it at the existing Apache configuration directories/server root as
> you are. You then just add snippets for additional configuration not handled
> by mod_wsgi-express. Setting up mod_kerb may be a bit fiddly to add as an
> extra, thus why keeping what you are doing for now and just configuring
> Django logging may well be better approach.
>
>> On 17 Dec 2018, at 1:20 pm, <>r.j.at <http://r.j.at/>[email protected]
>> <http://gmail.com/> wrote:
>>
>> Hi folks,
>>
>> TL;DR my app doesn't work because "Embedded mode of mod_wsgi disabled by
>> runtime configuration" and I don't know why...
>>
>> -- Background
>>
>> I've got an apache2/mod_wsgi docker environment set up for multiple (30-ish)
>> microservices to migrate to, but we've hit a major sticking point: these
>> docker containers all run in kubernetes, and have these requirements:
>>
>> - the service must run as PID 1, and
>> - all logging must go to stdout/stderr
>> - all logging must be in JSON format for ingest by ELK
>>
>> I've configured apache to sent ErrorLog and AccessLog to stdout, no
>> problems. I've also configured them to log JSON (not pretty, but it works).
>> The application (Django) is also configured to log JSON, and that's where
>> the problem comes in: apache captures *all* output from the Django app and
>> formats it into the ErrorLog, producing invalid JSON.
>>
>> I can't seem to get Django to circumvent apache's output capture. Getting
>> Django to log directly to /dev/stdout doesn't work.
>>
>> Graham suggested on twitter I should use mod_wsgi-express to solve my
>> logging problems, so the below is my current state of trying to get it
>> working.
>>
>> Our apache configuration is not trivial (amongst other things it includes
>> mod_kerb). I've developed the docker image using Debian slim (based off
>> existing work folks here have done with mod_kerb and other components) and
>> have followed the standard Debian apache configuration patterns. Through
>> benchmarking and load testing we've configured our servers and threads to
>> suit a particular memory usage model. So switching to mod_wsgi-express has
>> been ... challenging. I'm struggling to find documentation for
>> mod_wsgi-express - the PyPI page says docs are at www.modwsgi.org
>> <http://www.modwsgi.org/> but that says the docs are on PyPI. The
>> `start-server --help` is helping though I'm not entirely sure what the
>> difference between setup-server and start-server is (or if I even should
>> care).
>>
>> -- Where I'm stuck
>>
>> So far I've got this command line:
>>
>> mod_wsgi-express start-server --include-file /etc/apache2/apache2.conf
>> --server-root /etc/apache2 /app/main/wsgi.py
>>
>> My configuration is used \o/ though we configure StartServers and
>> ThreadsPerChild but those seem to be trumped by the --processes and
>> --threads command line options. Is there something I've missed here?
>>
>> That niggle aside, the application doesn't run. I get "Embedded mode of
>> mod_wsgi disabled by runtime configuration: /app/main/wsgi.py" I think it's
>> related to mod_wsgi "daemon" mode, but I can't see any mod_wsgi-express
>> option related to that. My wsgi.py is very simple:
>>
>> from django.core.wsgi import get_wsgi_application
>>
>> def application(env, start_response):
>> return get_wsgi_application()(env, start_response)
>>
>> My mod_wsgi-related apache configuration is:
>>
>> WSGIScriptAlias / /app/main/wsgi.py
>> WSGIPythonHome /venv
>> WSGIPythonPath /app
>>
>> So I'm not sure where to go from here...
>>
>>
>> Thanks,
>>
>> Richard
>>
>>
>> --
>> 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.