nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

The $logdir is not being created at runtime #790

Open alejandro-colomar opened 1 year ago

alejandro-colomar commented 1 year ago

The underlying issue is the same as https://github.com/nginx/unit/issues/742.

We fixed it for the ctrl socket and the pid file, and now need to do the same thing for the log file.

@ac000 are you busy with other stuff? Do you want to handle this one, or should I? The fix seems to be just repeating the other patch about the $runstatedir (https://github.com/nginx/unit/pull/747), this time with the $logdir.

Reported-by: Timo Stark <t.stark@nginx.com>
Reported-by: Alejandro Colomar <alx@nginx.com>
alejandro-colomar commented 1 year ago

If you don't beat me to it, I'll take a look at it on Monday.

ac000 commented 1 year ago

Yes, I'll take a look.

alejandro-colomar commented 1 year ago

Reconsidering:

We only created the last directory in the case of $runstatedir, because creating the whole path could hide some mistakes. We needed to create the last directory, because being in /run it would be wiped every time. But /var/log always exists. Unless we start using some subdirectory of /var/log by default (in which case it would make sense to wipe /var/log from time to time, and expect that unit re-creates /var/log/unit at startup if non-existent), I wouldn't try to create the directory. If the user is trying some rare non-standard setting, let the user mkdir(1) as appropriate.

I'd suggest WONTFIX.

CC: @thresheek @ac000 @tippexs

alejandro-colomar commented 1 year ago

For now, our default always exists.

As the FHS 3.0 suggests, I recomment moving to a subdirectory within /var/log: /var/log/unitd.

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s10.html:

This directory contains miscellaneous log files. Most logs must be written to this directory or an appropriate subdirectory.

For now, I won't close the issue, since I plan to address it after the default has been changed. However, since the defaults won't be changed for the next version of Unit, let's hold this fix.

My patches changing/adding the defaults are also on hold, and I'll push them for discussion again after the release 1.29.0.

andypost commented 5 months ago

Moreover according to FHS 3.0 usage of /var/run is deprecated but some scripts still using it, gonna file separate issue