services: nginx: Add reload action.

In a new "reload" shepherd-action, send a SIGHUP to the NGINX master process,
so that it can re-read the configuration file and start new worker processes.

* gnu/services/web.scm (nginx-shepherd-service): Add the "reload"
shepherd-action.

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
EuAndreh 2022-10-10 01:39:32 -03:00 committed by Christopher Baines
parent d8271d8193
commit a9268695e0
No known key found for this signature in database
GPG key ID: 5E28A33B0B84F577

View file

@ -807,7 +807,6 @@ (define (nginx-shepherd-service config)
#~#t #~#t
#~(read-pid-file #$pid-file)))))))) #~(read-pid-file #$pid-file))))))))
;; TODO: Add 'reload' action.
(list (shepherd-service (list (shepherd-service
(provision '(nginx)) (provision '(nginx))
(documentation "Run the nginx daemon.") (documentation "Run the nginx daemon.")
@ -815,7 +814,19 @@ (define (nginx-shepherd-service config)
(modules `((ice-9 match) (modules `((ice-9 match)
,@%default-modules)) ,@%default-modules))
(start (nginx-action "-p" run-directory)) (start (nginx-action "-p" run-directory))
(stop (nginx-action "-s" "stop"))))))) (stop (nginx-action "-s" "stop"))
(actions
(list
(shepherd-action
(name 'reload)
(documentation "Reload NGINX configuration file and restart worker processes.")
(procedure
#~(lambda (pid)
(if pid
(begin
(kill pid SIGHUP)
(format #t "Service NGINX (PID ~a) has been reloaded." pid))
(format #t "Service NGINX is not running."))))))))))))
(define nginx-service-type (define nginx-service-type
(service-type (name 'nginx) (service-type (name 'nginx)