dmachard / go-dnscollector

Ingesting, pipelining, and enhancing your DNS logs with usage indicators, security analysis, and additional metadata.
MIT License
184 stars 43 forks source link

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

Closed 4quarks closed 1 month ago

4quarks commented 2 months ago

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:

Additional Notes:

References:

Action Items:

dmachard commented 2 months ago

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 commented 1 month ago

This sounds perfect for us. Thanks!

dmachard commented 1 month ago

feature implemented in master branch

4quarks commented 1 month ago

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