2

I run heroku local with the Procfile:

web: start-nginx gunicorn -c gunicorn.conf.py app:app

start-nginx does some environment setup, and then ends with:

{ nginx --some-params & $@ ; }

the intention is to run both nginx and gunicorn side by side, and log everything.

It mainly works. The problem is that Python traceback is partial - the introductory "Traceback" line, and the first (useless for debugging, library) call, clipped, for example:

Traceback (most recent call last):
venv/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app

is all that I see, when the correct output from running start-nginx gunicorn ... directly:

Traceback (most recent call last):
File "/Users/ojf/project/venv/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
[25 more lines here]
AttributeError: [useful line]

What's the likely cause of this, and can I fix it by logging or handling stdout|err differently? Or is this a bug in heroku-local?


I also tried (instead of { a & b ; }):

nohup nginx --some-params 1>/tmp/log 2>&1 & echo $! > /tmp/nginx.pid
nohup $@ 1>/tmp/log 2>&1 & echo $! > /tmp/guni.pid
tail -f /tmp/log

in the script, with the only difference being that heroku-local stopped colouring the output.

3
  • Could you provide an example of the partial output versus what you want to see? (Stdout is line or block buffered by default, depending on the context, while stderr is unbuffered, which may have consequences for interleaving of the output.)
    – thrig
    Sep 30, 2015 at 21:18
  • @thrig Sorry should have included that to begin with. Clipped for brevity, but hope it's clear?
    – OJFord
    Sep 30, 2015 at 21:31
  • Agh - I just realised it actually is fine if invoked directly. It's using heroku local that messes with it.
    – OJFord
    Sep 30, 2015 at 21:35

1 Answer 1

1

Try setting output to be unbuffered:

  • in .env file set environment variable:

    PYTHONUNBUFFERED=True

  • or run with -u flag:

    python -u script.py

https://docs.python.org/3/using/cmdline.html#cmdoption-u

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .