1

I am using the official nginx unit docker image, And I would like to run a hello world wsgi application, and being able to print stuff on docker-compose output.

How can I do that ?

Here the hello world:

print('DURING INITIAL SETUP')

def application(environ, start_response):
  print('DURING REQUEST')
  start_response('200 OK', [('Content-Type', 'text/plain')])
  yield b'Hello, World!\n'

But nothing is ever written to the output... (I also tried writing directly to /proc/1/fd/1, but missing permissions)

hl037_
  • 3,520
  • 1
  • 27
  • 58
  • Does this answer your question: https://stackoverflow.com/a/61564350/2805824? – Gaurav Pathak Dec 31 '22 at 12:46
  • no : 1) I'm using nginx-unit, and your link is about nginx, 2) I'm talking about app logs, not nginx-units' own logs – hl037_ Dec 31 '22 at 13:06
  • 2
    Hi @hl037_ we are currently working on an rework of the application logging capabilities for unit. Feel free to open an github issue so we can keep track of it. Currently the `stdout` and `stderr` of an application process are redirected to `/dev/null`. You can create your own python logger but print will not work in this case. – Timo Stark Jan 02 '23 at 16:08
  • @TimoStark This could almost be an answer, thanks ! In the mean time, I indeed use a custom logger with a mounted volume, which allow me to `tail -f` the file. I also changed the ENTRY_POINT to execute flask when in dev mode. – hl037_ Jan 03 '23 at 16:04

0 Answers0