unit icon indicating copy to clipboard operation
unit copied to clipboard

The $logdir is not being created at runtime

Open alejandro-colomar opened this issue 2 years ago • 5 comments

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 <[email protected]>
Reported-by: Alejandro Colomar <[email protected]>

alejandro-colomar avatar Nov 25 '22 22:11 alejandro-colomar

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

alejandro-colomar avatar Nov 25 '22 22:11 alejandro-colomar

Yes, I'll take a look.

ac000 avatar Nov 26 '22 05:11 ac000

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 avatar Nov 26 '22 12:11 alejandro-colomar

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.

alejandro-colomar avatar Nov 26 '22 12:11 alejandro-colomar

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

andypost avatar Apr 20 '24 13:04 andypost