Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supervisor config for worker should set environment variable PYTHONUNBUFFERED #8194

Open
paulmueller opened this issue Apr 20, 2024 · 3 comments
Assignees

Comments

@paulmueller
Copy link
Contributor

paulmueller commented Apr 20, 2024

CKAN version

2.10.4

Describe the bug

While testing the background worker, I was not able to get any output of the worker processes to be written to the log files.

Steps to reproduce

# clear the logs
echo "" > /var/log/ckan/ckan-worker.stderr.log
echo "" > /var/log/ckan/ckan-worker.stdout.log

# restart the ckan worker via
supervisorctl stop ckan-worker:*`
supervisorctl start ckan-worker:*`

# create a test job
ckan jobs test default

# check whether anything is written to the logs
du /var/log/ckan/ckan-worker.stdout.log
# 4	/var/log/ckan/ckan-worker.stdout.log

Expected behavior

When I submit a test job, I would like to immediately see in the logs whether things work.

Problem and proposed solution

The problem is that Python by default buffers its output. While running ckan jobs worker default outputs the data directly into the terminal without any delay, running it with pipes attached buffers the output (can also be reproduced with ckan jobs worker default > test.log).

A very simple solution would be to set the PYTHONUNBUFFERED environment variable in the supervisor configuration file.

environment=PYTHONUNBUFFERED=1

I could create a PR for this if this is an acceptable solution. 🙏

@wardi
Copy link
Contributor

wardi commented Apr 22, 2024

We've set this in the dockerfile here

ENV PYTHONUNBUFFERED 1
would that be a better place for this setting? @EricSoroos

@EricSoroos
Copy link
Contributor

I think it's probably better to set in the supervisor config -- there's no real reason that we'd need to be changing that at the docker level, and it would just cause confusion for people not using the docker files.

@kowh-ai
Copy link
Contributor

kowh-ai commented Apr 24, 2024

The Dockerfile above is for GitHub Codespaces only. We don't, AFAIK change the default setting in any of our CKAN Dockerfiles or supporting config. If this change is made here I could make the same change in the ckan-docker-base repo so we are consistent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants