Skip to content
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

reattach to the syslog-ng console from syslog-ng-ctl #326

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

bazsi
Copy link
Member

@bazsi bazsi commented Oct 5, 2024

This PR allows syslog-ng-ctl to connect back to syslog-ng's original stdin/out/err fds and re-acqiure the output on those fds.

There are three subcommands:

# this just takes the stdio fds for 10 seconds and displays syslog-ng output in that time period
$ syslog-ng-ctl attach stdio --seconds 10

The other allows you to steal the log messages:

$ syslog-ng-ctl attach logs --seconds 10 --level trace

The other allows you to start the debugger on the new console:

$ syslog-ng-ctl attach debugger

There can only be one such attached process at any time.

@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from 789250c to 224ed6a Compare October 5, 2024 17:40
@bazsi bazsi changed the title Syslog ng ctl attach command reattach to the syslog-ng output/logs from syslog-ng-ctl Oct 5, 2024
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch 2 times, most recently from b3d4a68 to 8e81b73 Compare October 6, 2024 05:55
scratch_buffers_lazy_update_stats() uses the ivykis time state to check
if it is time to update the stats about scratch buffers. Do not
do that if ivykis is not initialized. This may happen in control threads and
the debugger threads that do use scratch buffers but don't use ivykis.

Signed-off-by: Balazs Scheidler <[email protected]>
A better solution would be to have a connection specific worker list,
and a list of connections. But for now this suffices for my purposes
of being able to cancel connection specific workers.

Signed-off-by: Balazs Scheidler <[email protected]>
Up to now, control worker threads were only cancelled at exit. Truth be
told we never really detected if the peer has disconnected either.

This patch implements thread cancellation whenever a connection closes,
to detect the closure of the connection comes in a separate patch.

Signed-off-by: Balazs Scheidler <[email protected]>
This will be used to pass over the stdio file descriptors from syslog-ng-ctl
so we can attach to the syslog-ng process after it was started in the
background.

Signed-off-by: Balazs Scheidler <[email protected]>
This new command allows to reconnect the stdio streams even if syslog-ng
runs in the background.  syslog-ng-ctl will be able to pass 3 fds to the
syslog-ng process, which will be duplicated into the standard fds and with
that syslog-ng will happily start displaying its stdout to that terminal.

The ATTACH command itself is threaded and the control socket is only used to
indicate that the peers are still alive.  syslog-ng will start sending
"ALIVE" messages to this stream every second or so.  If sending this packet
is not successful, the connection is closed and the thread is cancelled.
Upon cancellation, the stdio fds are restored to point to /dev/null.

Signed-off-by: Balazs Scheidler <[email protected]>
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from 8e81b73 to cf46e3d Compare October 6, 2024 08:44
@bazsi bazsi changed the title reattach to the syslog-ng output/logs from syslog-ng-ctl reattach to the syslog-ng console from syslog-ng-ctl Oct 6, 2024
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from cf46e3d to 3db4f22 Compare October 6, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant