-
Notifications
You must be signed in to change notification settings - Fork 271
openrc-run: default supervisor stdout and stderr to logger #783
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
base: master
Are you sure you want to change the base?
Conversation
Currently we redirect any stdout and stderr output to /dev/null. This is making debugging, or helping others debug, unnecessarily harder, so let's just assign a sane default that should work on most systems.
3601bb1 to
d1bf426
Compare
|
I'm not sure if this is a good idea. User can just enable logging if they need to? But to underscore my point, "sane default" is subjective, and I think Adding Also manpages describe that "Cmd must be an absolute pathname". So the current default in this PR may not work with chroot. |
|
systemd and s6 both have catch-all loggers, though to journald and s6-log respectivelly and that immensely helps catching issues, specially when you might not know what happened in a server until it's way after, or when trying to help people debug intermittent issues differently than systemd and s6 tho, we don't ship a logger-- but posix logger is standard and given openrc's nature, fits as our default logger text doesn't use a lot of space, default configs for syslogds now a days have logrotate enabled by default, and most well behaving daemons don't spew a lot of trash in std{out,err} anyway- the use case for this is exactly the cases where people won't think of setting up a logger, to later figure out they should've |
This is an important point because it means that unlike systemd, openrc users need to manually install and configure a logger to begin with. And so setting a value to
The posix logger defines no option (or anything else really) so the options used in this PR aren't exactly "posix". |
logger is required by posix, and thus we can assume it'll be available in a posix system, and nothing really breaks if there's no syslogd set up (posix defines the logger tool to be implementation, it might not even use a syslogd depending on the platform) setting rc_*_logger is not a big deal if people are aware of it, getting aware of it after things go wrong and there's no log about it is the not great is an awful experience, seeing a few log lines and wanting to turn that off is a better one
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/logger.html posix logger does define every option i've used here since posix.2024, so it is posix (except for the |
Okay, I see. My local manpages didn't include it.
There's 3 scenarios here. 1. Default case of user not configuring any logging.And I don't mean the In this case, enabling logging by default doesn't help in the situation you're describing. 2. Logging configured, logger manually set for services/openrcAlso doesn't help. 3. Logging configured, logger not set for services/openrcThis is the only situation where setting it helps. Okay so how about this: if It will help in situation 3 while also not spawning a bunch of useless logger process in situation 1. |
|
Just to throw this in here as an idea (based on the above discussion whether That should also workaround the "logger may itself crash"-issue which @navi-desu mentioned in #806 (comment). Of cause, the supervise-daemon may itself still crash but that we cannot mitigate with the current architecture anyhow. |
This is a misunderstanding of the point. "Logging configured" here refers to the init script as well. We can assume users have a syslog if they want the logging. If not, not our problem, and they can override it if they wish too. Option 3 is precisely the one we're concerned about, and the most common scenario from speaking to very confused users and folks writing init scripts.
I'm not sure if this is robust if the logger isn't up yet or gets restarted. |
|
I'm worried about wear and tear of SSD and HDD, caused by excessive logging. Some services might print a lot. I want to minimize unnecessary logging. In my experiences, SSDs don't last very long. |
|
I don't think that's relevant to this bug, sorry. You're free to still configure your syslog daemon appropriately, override the defaults, etc. Also, daemons tend to be very quiet on std*? The issue here is output being lost when they fail. |
|
In my experiences, some daemons can be verbose on stdout or stderr. At one point, I didn't configure log rotation, so /var became full. If openrc runs on microSD card, minimizing logging will be important. Logging eats up precious write cycles of microSD cards. I don't like the idea of logging everything by default. |
|
You'll have issues with other software already. Note that Again, this isn't the place, sorry. I don't want to litigate your position on logging overall. The issue here is init scripts being hostile to debugging and valuable information being lost, which often surprises people. |
|
while the implementation in this pr isn't quite what's gonna get merged, whatever we merge will be a default -- meaning you'll be able to override it in rc.conf should you be concerned with logfiles |
|
When a service crashed, I looked in If you want to improve discoverability of logging facility, logging can be documented outside
https://wiki.gentoo.org/wiki/Openrc can say |
As we said above, we don't consider needing to do that to debug a failing service to be reasonable for default behaviour. |
|
At least, don't log onto /var/log/messages where everything is bundled together and difficult to find. |
|
One problem with sending everything to syslog is that syslog records everything onto /var/log/messages. Even though I had a separate log file for each user service, I preferred deleting user service logs before logging in again because I was disoriented by logs from previous login sessions. There should be an easier way to browse logs. At least, emptty rotates its own logs whenever I log in. Thus, I can see the logs from the current login session. Emptty basically sends logs from the previous login session to archives. I want to be able to easily dig up current session logs and previous session logs for each user service. |
|
That depends on the syslog implementation you choose and its configuration. |
|
One problem with this is the order of shutdown. If sway shuts down before openrc user services do, some openrc user services will log useless errors that will make users think there are errors when there aren't. If OpenRC user services quit before sway does, then there is no error. How can I make sure all (graphical) OpenRC user services quit before exiting sway? |
|
eventually running sway as a user service (similar to how niri uses systemd) would work for this |
|
emptty executes sway directly. I don't know how emptty would track sway if it's run as a user service. |
|
Is there an openrc command that waits until all (graphical runlevel) OpenRC user services are shut down? |
|
As I've asked several times now, please ask them in a new bug or "discussion" thing on GitHub, not on this PR. |
|
I just executed |
|
@amano-kenji the proper place to ask question is https://github.com/OpenRC/openrc/discussions |
|
Stumbled independently into this issue In the first place, there needs to be BY DEFAULT CONFIGURATION logging for any openrc components itself. Specifically openrc-user.sh, to catch errors in the software by the sysadmin without having to tinker around with configs: As a sysadmin, i do not want to have to do a gigantic strace through OpenRC to catch an issue like this (but i had to do it): 16445 dup2(3, 1) = -1 EBADF (Bad file descriptor) This btw was because of user's shell being tcsh which closed the FD 3 in before. I thought there is a good amount of system software which simply logs directly to log files, such as software Foo to something like /var/log/Foo/errors.log or the like. I'd expect OpenRC to do this as well by default. No external logger needed. In any case, HOW TO LOG should not be used as an excuse NOT TO LOG. Logging of the user started software is another issue all together IMHO. I still have not found any documentation exactly how those openrc user daemons are meant to be managed by the user (for gentoo), so i am not even sure if the software is just meant to be started from ~/.profile or also other ways. That makes it hard to give advice how to log for it. IMHO, OpenRC can not by default log output from any user started software to system files. I remember managing unix systems for hundreds of students with X11. First of all, you do not want system logfiles to necessarily be readable by such users (simplifies hacking), and of course it would easily fill up disks when users start stuff that logs too much. And if OpenRC is not really brutal ensuring all user started daemons are killed after session terminates, logging will be even more of an issue. In other words: The logfile for user daemons needs to go ultimately into some user quota file. Like in the user directory. If there is no good precedent how to best do this, then it's perfectly fine to just give some example how to set it up. E.g.: some ~/.profile stub to enable such logging to some ~/.openrc_log/daemon-name.log approach. |
we provide a pam module, and a system wide init script. all of: via pam session using pam_openrc, manually by starting user.$USER (e.g. at boot), or manually by calling
if we do end up using logger, it would send those to syslog, and thus syslogd's responsability to split them, so, responsibility of the admin to configure their syslogd properly however, there are good reasons to not use syslog, the main one being having a deterministic path for logs allows
$XDG_STATE_HOME is the place to do it, by the xdg basedirs spec: https://specifications.freedesktop.org/basedir-spec/latest/ |
|
Please stop writing COMMENTS WITH LOTS OF CAPS. |
Currently we redirect any stdout and stderr output to /dev/null. This is making debugging, or helping others debug, unnecessarily harder, so let's just assign a sane default that should work on most systems.