Closed irsl closed 1 year ago
Could you move all the path resolution stuff to the earliest point possible? That includes stderrPath and TranscodeLogPath. That way you can handle errors resolving the user home etc. where it's suitable too. Also the special casing for /dev
isn't ideal, is there someway to improve or remove that? I would rather another flag or something for that.
How about calling it -transcodeLogPattern
that would support a [tsName]
placeholder to be substituted in serveDLNATranscode
?
This aproach would fit well the following use cases:
$HOME/.dms/log/[tsname]
) one for each video/dev/null
)/dev/stderr
)The last one is useful in a container environment where the container runtime takes care about log rotation/retention.
That sounds fair. Can you do that with resolving it early too? Expose the necessary configuration fields wherever they're used and compute their values after flag parsing rather than on on demand for each log site.
Yup, that will require adding a new user in Dockerfile - otherwise early resolution would break it, even if transcoding is never used. I will take care of that.
Refactored as discussed. TDD of the early error before the Dockerfile is adjusted:
root@a798962a645e:/data/fileserver-geza/dms# docker run --rm -it dmsx
2023-04-02T19:14:55+0000 NIL [main.getDefaultFFprobeCachePath:83]: user: unknown userid 1000
2023/04/02 19:14:55 error in main: unable to resolve current user: "user: unknown userid 1000"
This change also addresses the issue raised in https://github.com/anacrolix/dms/pull/113, when user lookup fails in a docker container, logging will be silently turned off (instead of panicing). Tested with the following dynamic stream:
"Command": "bash -c 'echo stdout; >&2 echo stderr'"
Some earlier formatting mistakes (of mine) should also be fixed in README.rst.