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

Logging: Redirect stdout from child processes to Supervisor #432

Closed
microamp opened this issue Apr 23, 2024 · 0 comments · Fixed by #434
Closed

Logging: Redirect stdout from child processes to Supervisor #432

microamp opened this issue Apr 23, 2024 · 0 comments · Fixed by #434
Labels
internal Fix internally

Comments

@microamp
Copy link
Contributor

Currently, only Supervisor logs would appear when we run

kubectl logs -f www-wagtail-...
2024-04-22 23:57:48,162 INFO supervisord started with pid 1
2024-04-22 23:57:49,164 INFO spawned: 'gunicorn' with pid 7
2024-04-22 23:57:49,165 INFO spawned: 'nginx' with pid 8
2024-04-22 23:57:50,282 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-04-22 23:57:50,282 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
...

which is consistent with what we are seeing in Grafana.

2024-04-20 18:46:22,662 INFO supervisord started with pid 1
2024-04-20 18:46:23,665 INFO spawned: 'gunicorn' with pid 6
2024-04-20 18:46:23,666 INFO spawned: 'nginx' with pid 7
2024-04-20 18:46:24,884 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-04-20 18:46:24,884 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
...

It would be very useful to be able to view all logs from the child processes in Grafana as well.

Consider redirecting logs from Nginx and Gunicorn processes to Supervisor so that they can be picked up by the Grafana agent. One way to do that is to explicitly set the log file to /dev/stdout with log rotation disabled.

/dev/stdout is a symlink to /proc/self/fd/1. When a process opens that file, the system actually clones file descriptor #1 (stdout) of that process. Using this as stdout_logfile therefore causes supervisord to redirect the program’s stdout to its own stdout (from where it will be captured by Docker)

https://veithen.io/2015/01/08/supervisord-redirecting-stdout.html

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

Successfully merging a pull request may close this issue.

1 participant