-
Notifications
You must be signed in to change notification settings - Fork 632
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
Support log rotation #6009
Comments
I don't think log rotation will be implemented in nearcore itself. It should be done on the devops side. @mhalambek can provide more details. |
Should I address @mhalambek directly or wait for instructions here? Here would be better as this is a publicly available thread. |
@mintiayields @bowenwang1996 I think we should address the performance of the logger issue first. Current logger is too slow by a factor of 30, and that's affecting our service. See #6072 My plan is to change, the way we use logging, and then adding features like log rotation would be easy to do. |
This issue has been automatically marked as stale because it has not had recent activity in the last 2 months. |
I am actually surprised that Ideally neard would handle SIGHUP and reopen the log file but that is not currently supported.
This will only remove the dentry. The fill will remain on the filesystem but it will be inaccessible. So as neard runs the log will accumulate in size.
That’s not quite true. nearup rotates logs but only on startup. It does not support rotating while the daemon is running. |
|
Handling SIGHUP would have an advantage that one could configure logrotate to rotate the logs based on size rather than schedule. Also, if we do rotation inside neard than we need to expose the schedule option to the user and if we just handle SIGHUP than configuring the schedule goes into logrotate configuration and we don’t need to care about it. |
Support traditional Linux log rotation. To make this work we need to be able to configure neard to save logs to a file and then have a mechanism to tell it to close the log file descriptor and reopen it.
The way this traditionally works on Linux servers is:
PR #6666 added handler for SIGHUP which reconfigures log levels and we might be able to leverage that work. What remains is:
--log-output=<file>
flag though now that we havelog_config.json
and SIGHUP handler which reads it adding output file there might be best option).I (@mina86) think the hardest part of this is figuring out tracing crate. We need to tell it to save to a log file and then also we need to be able to tell it to reopen the file. But this opinion comes from ignorance of tracing crate so perhaps it’s actually trivial to do.
— >8 — original report by @mintiayields below
When logs are redirected in the service file like, for instance: StandardOutput=append:/home//.near/neard.log StandardError=inherit
at this point nearcore keeps the file open for writing all the time and will not allow any log rotation. It will not even allow to truncate it to a certain size. I played around with bash scripts in an attempt to truncate the contents or rotate the log. The results are as follows:
The text was updated successfully, but these errors were encountered: