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

Merged
merged 10 commits into from
Nov 7, 2024

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 3 times, most recently 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
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from 3db4f22 to 6dcf9ab Compare October 27, 2024 11:29
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from 6dcf9ab to aa64599 Compare November 7, 2024 09:47
bazsi added 5 commits November 7, 2024 10:59
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]>
@bazsi bazsi force-pushed the syslog-ng-ctl-attach-command branch from aa64599 to 04b742d Compare November 7, 2024 10:00
bazsi added 5 commits November 7, 2024 15:14
To avoid being racy.

Signed-off-by: Balazs Scheidler <[email protected]>
We don't need this anymore.

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 04b742d to fa16ac6 Compare November 7, 2024 14:22
@alltilla alltilla merged commit 2f5b414 into axoflow:main Nov 7, 2024
22 checks passed
fekete-robert pushed a commit to axoflow/axosyslog-core-docs that referenced this pull request Nov 9, 2024
alltilla added a commit to alltilla/axosyslog that referenced this pull request Nov 11, 2024
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.

2 participants