diff options
| author | Alexey Abramov <levenson@mmer.org> | 2025-05-08 19:47:43 +0200 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-05-16 17:01:11 +0900 |
| commit | efcf1a233410797e092a3b413269575fd1b04afd (patch) | |
| tree | 9dd794d2156913dba90372699861bfb0b37e08e0 /gnu/services | |
| parent | 50126b39aceb203c16596a433141dd71218c94fb (diff) | |
services: dnsmasq: Add stats and reload shepherd actions.
* gnu/services/dns.scm (dnsmasq-service-reload-action): New function.
Implements SIGHUP handling for reloading configurations.
(dnsmasq-service-stats-action): New function. Implements SIGUSR1
handling for dumping statistics.
(dnsmasq-shepherd-service): Use new actions.
* doc/guix.texi: Document new actions with examples.
* gnu/tests/networking.scm (%test-dnsmasq): Add tests to verify the
functionality of new actions.
Change-Id: I31f0eb4b26a582e95f7bfdb240110c139f0e16cc
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu/services')
| -rw-r--r-- | gnu/services/dns.scm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index d55ee3e4fcb..9a9b78d877b 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm | |||
| @@ -874,6 +874,8 @@ cache.size = 100 * MB | |||
| 874 | (provision (or provision shepherd-provision)) | 874 | (provision (or provision shepherd-provision)) |
| 875 | (requirement shepherd-requirement) | 875 | (requirement shepherd-requirement) |
| 876 | (documentation "Run the dnsmasq DNS server.") | 876 | (documentation "Run the dnsmasq DNS server.") |
| 877 | (actions (list (dnsmasq-service-reload-action config) | ||
| 878 | (dnsmasq-service-stats-action config))) | ||
| 877 | (start #~(make-forkexec-constructor | 879 | (start #~(make-forkexec-constructor |
| 878 | (list | 880 | (list |
| 879 | #$(file-append package "/sbin/dnsmasq") | 881 | #$(file-append package "/sbin/dnsmasq") |
| @@ -965,6 +967,26 @@ cache.size = 100 * MB | |||
| 965 | ;; create directory to store dnsmasq lease file | 967 | ;; create directory to store dnsmasq lease file |
| 966 | (mkdir-p "/var/lib/misc"))) | 968 | (mkdir-p "/var/lib/misc"))) |
| 967 | 969 | ||
| 970 | (define (dnsmasq-service-reload-action config) | ||
| 971 | (match-record config <dnsmasq-configuration> () | ||
| 972 | (shepherd-action | ||
| 973 | (name 'reload) | ||
| 974 | (documentation "Send a @code{SIGHUP} signal to @command{dnsmasq} to clear | ||
| 975 | cache and reload hosts files.") | ||
| 976 | (procedure #~(lambda (running) | ||
| 977 | (let ((pid (process-id running))) | ||
| 978 | (kill pid SIGHUP))))))) | ||
| 979 | |||
| 980 | (define (dnsmasq-service-stats-action config) | ||
| 981 | (match-record config <dnsmasq-configuration> () | ||
| 982 | (shepherd-action | ||
| 983 | (name 'stats) | ||
| 984 | (documentation "Send a @code{SIGUSR1} to write statistics to the system | ||
| 985 | log.") | ||
| 986 | (procedure #~(lambda (running) | ||
| 987 | (let ((pid (process-id running))) | ||
| 988 | (kill pid SIGUSR1))))))) | ||
| 989 | |||
| 968 | (define dnsmasq-service-type | 990 | (define dnsmasq-service-type |
| 969 | (service-type | 991 | (service-type |
| 970 | (name 'dnsmasq) | 992 | (name 'dnsmasq) |
