tethysplatform / tethys

The Tethys Platform main Django website project repository.
http://tethysplatform.org/
BSD 2-Clause "Simplified" License
94 stars 51 forks source link

Fix Docker log tailing #1066

Closed gronka closed 4 months ago

gronka commented 4 months ago

Change the long-lived process from supervisord to tail, and prepend tail lines with the name of the file.

Description

Fixes this issue: https://github.com/tethysplatform/tethys/issues/1048

Changes Made to Code:

Related

Additional Notes

Quality Checks

coveralls commented 4 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling 18719c2575b004960666c6eb03406b40e9478c0a on gronka:fix-tail into 71ea0c8e168b35f33957d6b8b469aa165388a31a on tethysplatform:main.

gronka commented 4 months ago

I made some 2 changes recommended by @araglu. I think the variable name PREFIX is a much better name, and using sed with --unbuffered makes new lines output immediately, which is a significantly better experience when working locallly with docker-compose.

swainn commented 4 months ago

Hey @gronka I just tested this locally and I'm seeing a lot of these errors and no helpful logging:

run.sh: line 2: $'\r': command not found
run.sh: line 3: syntax error near unexpected token `$'{\r''
run.sh: line 3: `tail_file() {

Looks like some carriage return characters are causing issues maybe?

swainn commented 4 months ago

Looks like some carriage return characters are causing issues maybe?

That was the problem I think. I opened the file in VSCode and it was show CRLF line endings. I changed it to LF, and it replaced all the line ending and is working now.

image

gronka commented 4 months ago

@swainn Thanks for figuring it out. I program in linux, so I don't know where an \r could possibly come from. Maybe it had to do with rebasing after you updated my PR to main, and then I tried to update my own branch to main - you can see I ended up duplicating commit messages. I'm a bit lost on the process here, sorry.

I don't have CRLF in my files, so I'm not sure how to proceed. I just deleted my repo and cloned it, and I still don't see any CLRF.

Is this PR now a hidden branch in the tethysplatform repository?

gronka commented 4 months ago

I usually add * text=auto to .gitattributes, which might be nice here (probably not with * in this repo).

I think I was able to check out this PR branch with git fetch origin pull/1066/head:fix-tail. Is that correct? I still don't see any CRLF. dos2unix doesn't seem to change the file

swainn commented 4 months ago

I don't have CRLF in my files, so I'm not sure how to proceed. I just deleted my repo and cloned it, and I still don't see any CLRF.

Hey I think I figured out what was going on. I built the Docker image for testing using Docker Desktop in Windows, so I bet the line endings go changed when I checked it out in windows. I just tested as-is in linux and it worked great. Sorry for the confusion.