-
Notifications
You must be signed in to change notification settings - Fork 20
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
console: io backup restore #525
base: main
Are you sure you want to change the base?
Conversation
f096a01
to
f9d4706
Compare
{ "log-level", 0, 0, G_OPTION_ARG_CALLBACK, _store_log_level, "change syslog-ng log level", "<default|verbose|debug|trace>" }, | ||
{ "forever", 'f', 0, G_OPTION_ARG_NONE, &attach_options_forever, "do not pass logs/stdio back to syslog-ng after syslog-ng-ctl is exited", NULL }, | ||
{ "dont-release", 'd', 0, G_OPTION_ARG_NONE, &attach_options_dont_release_console, "do not pass logs/stdio back to syslog-ng after syslog-ng-ctl is exited and keep logging onto the calling console" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when would we use these options? I'd not add them if possible. I do think that restoring the original console makes a lot of sense though.
One mode which we would need is where syslog-ng-ctl is actively reading the fds and writes them to its own stdout/stderr, so that we can grep the output.
Right now, the console redirection works but it cannot be filtered by grep, even if added to the end of the syslog-ng-ctl command line using a pipe.
e.g. this does not work: "syslog-ng-ctl attach logs | grep whatever"
All the logs will be dumped to stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just simply wanted to keep your original implementation at the same time (I just forgot to apply the --forever
flag in the final version in mainloop-control)
Not restoring the original fd
s (--forever
option) in syslog-ng might make sense sometimes, e.g. if the ctl caller wants to redirect the output fully, but wants to interrupt the local output sometimes then continues.
The --dont-release
might make sense too if the ctl caller wants to exit immediately but keep the log flow to the current terminal (that also will free the syslog-ng _wait_until_peer_disappears
thread nicely)
I think the piping/grep issue is independent of this change, it is an issue with the original implementation, but yes, it must be fixed, which I'll look at.
Also, I'd like to add a new option to control which fd
s the caller wants to attach to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Agreed, that the piping/grep issue is independent, I was just mentioning it, as it was something I wanted to do at the original implementation but never got around to do it.
-
the primary purpose of attaching to the stdio fds came as an idea as I wanted to attach to the "debugger" portion of syslog-ng. The logs command only came as an extra idea, as it is usually very difficult to get the internal logs if syslog-ng is running in the background and it was simple to add.
-
I don't think redirecting the console and keeping it there for a longer period is an important use-case, that's why I was asking what was the intention, I might be missing a useful thing there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, the console redirection works but it cannot be filtered by grep, even if added to the end of the syslog-ng-ctl command line using a pipe.
e.g. this does not work: "syslog-ng-ctl attach logs | grep whatever"
All the logs will be dumped to stdout.
This is related to my previous question in the global comments.
The actual behavior you described is normal, we redirect all the fd
s to their matching handles on the caller ctl console, so, there is no message on the stdout currently, syslog-ng logs the log_stderr
(attach logs
) onto the stderr as expected.
Please describe the required redirections for each of the attach
targets as I questioned bellow to be able to fix these.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Agreed, that the piping/grep issue is independent, I was just mentioning it, as it was something I wanted to do at the original implementation but never got around to do it.
This is now normal as I described above, but can be handled easily like
syslog-ng-ctl attach logs --seconds 500 2>&1 | grep cURL
I do not think I will try to fix this as it would require an even more complex logic in the redirection (e.g. in case attach logs
redirecting stderr to the caller's stdin instead of the matching pair)
f9d4706
to
ece79b0
Compare
@bazsi the What are the intended, valid combinations that we would like to support here? My bets are STDIO option -> only STDIO Could you please confirm? |
I think we only need to handle one case at a time. And We should restore to the original console (as you implemented) when we finish with any of these commands, so the next one can properly run.
I hope I addressed these with the response above. Let me know if it didn't or ping me on discord/reddit to chat. |
Signed-off-by: Hofi <[email protected]>
…hed its attached work Signed-off-by: Hofi <[email protected]>
Signed-off-by: Hofi <[email protected]>
ece79b0
to
2dc8887
Compare
console: add support for restoring the original console io handlers after an attached control client has finished its work
added optional ATTACH arguments to be able to control this better
--forever
: aftersyslog-ng-ctl attach logs\stdio
exits it will not redirect stdio/logs to syslog-ng--dont-release
:after syslog-ng-ctl attach logs\stdio
exits it will not redirect stdio/logs to syslog-ng and will not release the stolen console so that all syslog-ng output will be continuously presented in the console syslog-ng-ct was invoked fromSigned-off-by: Hofi [email protected]