mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
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>
This commit is contained in:
parent
50126b39ac
commit
efcf1a2334
3 changed files with 175 additions and 0 deletions
|
@ -874,6 +874,8 @@ cache.size = 100 * MB
|
|||
(provision (or provision shepherd-provision))
|
||||
(requirement shepherd-requirement)
|
||||
(documentation "Run the dnsmasq DNS server.")
|
||||
(actions (list (dnsmasq-service-reload-action config)
|
||||
(dnsmasq-service-stats-action config)))
|
||||
(start #~(make-forkexec-constructor
|
||||
(list
|
||||
#$(file-append package "/sbin/dnsmasq")
|
||||
|
@ -965,6 +967,26 @@ cache.size = 100 * MB
|
|||
;; create directory to store dnsmasq lease file
|
||||
(mkdir-p "/var/lib/misc")))
|
||||
|
||||
(define (dnsmasq-service-reload-action config)
|
||||
(match-record config <dnsmasq-configuration> ()
|
||||
(shepherd-action
|
||||
(name 'reload)
|
||||
(documentation "Send a @code{SIGHUP} signal to @command{dnsmasq} to clear
|
||||
cache and reload hosts files.")
|
||||
(procedure #~(lambda (running)
|
||||
(let ((pid (process-id running)))
|
||||
(kill pid SIGHUP)))))))
|
||||
|
||||
(define (dnsmasq-service-stats-action config)
|
||||
(match-record config <dnsmasq-configuration> ()
|
||||
(shepherd-action
|
||||
(name 'stats)
|
||||
(documentation "Send a @code{SIGUSR1} to write statistics to the system
|
||||
log.")
|
||||
(procedure #~(lambda (running)
|
||||
(let ((pid (process-id running)))
|
||||
(kill pid SIGUSR1)))))))
|
||||
|
||||
(define dnsmasq-service-type
|
||||
(service-type
|
||||
(name 'dnsmasq)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue