I have a systemd service with gunicorn. I have a print statement in a function.Problem is that, journalctl does not show the print output when i call the function but it shows the output after refresing the systemd service unit. Should it behave like this? What could be the solution for this?
Asked
Active
Viewed 1,786 times
1 Answers
2
This is due to Python's default behavior to buffer stdin, stdout and stderr. For a systemd file, include the following line within the same block as ExecStart=/path/to/gunicorn
.
Environment=PYTHONUNBUFFERED=1
Refer to https://stackoverflow.com/questions/107705/disable-output-buffering for alternative ways to disable it.

MarkM
- 121
- 3