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

Implement PID File for go-dnscollector to Enable SIGHUP Configuration Reload #722

Closed
2 tasks
4quarks opened this issue May 29, 2024 · 4 comments
Closed
2 tasks

Comments

@4quarks
Copy link

4quarks commented May 29, 2024

Implement PID File for go-dnscollector to Enable SIGHUP Configuration Reload

Description:
Now that SIGHUP is implemented on the go-dnscollector side (see), we (pDNSSOC) need to integrate this functionality for configuration reload without restarting the process. This will allow us to make changes on-the-fly, such as reading updated files, by sending a SIGHUP signal to the process without having to restart the process manually.

Background:
It became common practice for daemonized processes to use SIGHUP for configuration reload. This allows changes to be made without terminating the process.

Current Implementation Steps:

  1. Find the process number of go-dnscollector.
  2. Run the following command to reload the configuration:
    kill -SIGHUP 21371  # Assuming 21371 is the PID of the running go-dnscollector

Challenge:
The PID changes every time the process restarts, which makes it difficult to automate this with a static command.

Proposed Solution:
Implement a PID file in go-dnscollector that stores the current PID of the running process. This PID file will be created on startup and can be referenced to send the SIGHUP signal.

Benefits:

  • Simplifies the process of sending SIGHUP signals.
  • Eliminates the need to restart the process for configuration changes.
  • Potentially allows us to remove the dependency on supervisord, as it is currently used only for restarting on config changes.
  • Follows a good and common industry practice.

Additional Notes:

  • Confirm if Denis has implemented the PID file functionality. If not, this issue should prioritize that implementation.
  • If we (pDNSSOC) can ditch supervisord, a Python script inside fetch-iocs can monitor file changes and send the SIGHUP signal accordingly.

References:

Action Items:

  • Implement PID file creation in go-dnscollector.
  • We (pDNSSOC) will have to create a script to read the PID from the PID file and send the SIGHUP signal.
@dmachard
Copy link
Owner

My proposal

Add global settings to enable PID file creation.

global:
  pid-file: "/path/to/your/pidfile.pid"

By default, this setting will be empty. If the pid-file parameter is configured, the program will create a PID file.

@4quarks
Copy link
Author

4quarks commented May 30, 2024

This sounds perfect for us. Thanks!

@dmachard
Copy link
Owner

feature implemented in master branch

@dmachard dmachard added this to the v0.46.0 milestone May 31, 2024
@4quarks
Copy link
Author

4quarks commented Jun 6, 2024

The issue seems to be resolved. Thanks for your quick action!

@4quarks 4quarks closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants