Allow services to implement a 'reload' action

  • Open
  • quality assurance status badge
Details
One participant
  • Clément Lassieur
Owner
unassigned
Submitted by
Clément Lassieur
Severity
important

Debbugs page

C
C
Clément Lassieur wrote on 8 May 2017 08:25
(address . guix-patches@gnu.org)
87d1bjtlpd.fsf@lassieur.org
Hi,

The first patch allows services to implement a 'reload' action, and the
other three implement the 'reload' action for nginx, prosody and
dovecot.

Services do not have to implement 'reload' and if, say, foo-daemon
doesn't implement it, 'herd reload foo-daemon' will return 1 and display
a message saying that foo-deamon does not have an action 'reload'.
That's the reason of the #f default value.

WDYT?
C
C
Clément Lassieur wrote on 8 May 2017 08:28
[PATCH 1/4] services: shepherd: Allow services to implement a 'reload' action.
(address . 26830@debbugs.gnu.org)
20170508152832.4797-1-clement@lassieur.org
* gnu/services/shepherd.scm (<shepherd-service>)[reload]: Add it.
(shepherd-service-file): Add it to the Shepherd's service definition.
* doc/guix.texi (Services): Update accordingly.
---
doc/guix.texi | 7 ++++---
gnu/services/shepherd.scm | 9 ++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)

Toggle diff (54 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 4446909ed..3ccfa8d9e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8671,9 +8671,10 @@ service:
Run libc's name service cache daemon (nscd).
@end example
-The @command{start}, @command{stop}, and @command{restart} sub-commands
-have the effect you would expect. For instance, the commands below stop
-the nscd service and restart the Xorg display server:
+The @command{start}, @command{stop}, @command{restart} and
+@command{reload} sub-commands have the effect you would expect. For
+instance, the commands below stop the nscd service and restart the Xorg
+display server:
@example
# herd stop nscd
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 7281746ab..17e53f774 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -47,6 +47,7 @@
shepherd-service-respawn?
shepherd-service-start
shepherd-service-stop
+ shepherd-service-reload
shepherd-service-auto-start?
shepherd-service-modules
@@ -137,6 +138,8 @@ for a service that extends SHEPHERD-ROOT-SERVICE-TYPE and nothing else."
(start shepherd-service-start) ;g-expression (procedure)
(stop shepherd-service-stop ;g-expression (procedure)
(default #~(const #f)))
+ (reload shepherd-service-reload ;g-expression (procedure)
+ (default #f))
(auto-start? shepherd-service-auto-start? ;Boolean
(default #t))
(modules shepherd-service-modules ;list of module names
@@ -214,7 +217,11 @@ stored."
#:requires '#$(shepherd-service-requirement service)
#:respawn? '#$(shepherd-service-respawn? service)
#:start #$(shepherd-service-start service)
- #:stop #$(shepherd-service-stop service))))))
+ #:stop #$(shepherd-service-stop service)
+ #:actions (make-actions
+ (reload
+ "Reload the service's configuration files."
+ #$(shepherd-service-reload service))))))))
(define (shepherd-configuration-file services)
"Return the shepherd configuration file for SERVICES."
--
2.12.2
C
C
Clément Lassieur wrote on 8 May 2017 08:28
[PATCH 2/4] gnu: services: nginx: Add a 'reload' action.
(address . 26830@debbugs.gnu.org)
20170508152832.4797-2-clement@lassieur.org
* gnu/services/web.scm (nginx-shepherd-service): Add it.
---
gnu/services/web.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

Toggle diff (30 lines)
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index f85b41215..956aa1518 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
;;; Copyright © 2016, 2017 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -262,13 +263,13 @@ of index files."
run-directory server-blocks upstream-blocks))
#$@args))))))
- ;; TODO: Add 'reload' action.
(list (shepherd-service
(provision '(nginx))
(documentation "Run the nginx daemon.")
(requirement '(user-processes loopback))
(start (nginx-action "-p" run-directory))
- (stop (nginx-action "-s" "stop"))))))))
+ (stop (nginx-action "-s" "stop"))
+ (reload (nginx-action "-s" "reload"))))))))
(define nginx-service-type
(service-type (name 'nginx)
--
2.12.2
C
C
Clément Lassieur wrote on 8 May 2017 08:28
[PATCH 3/4] gnu: services: prosody: Add a 'reload' action.
(address . 26830@debbugs.gnu.org)
20170508152832.4797-3-clement@lassieur.org
* gnu/services/messaging.scm (prosody-shepherd-service): Add it.
---
gnu/services/messaging.scm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Toggle diff (16 lines)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index 715d6181f..1f357c1c5 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -582,7 +582,8 @@ See also @url{http://prosody.im/doc/modules/mod_muc}."
(provision '(prosody xmpp-daemon))
(requirement '(networking syslogd user-processes))
(start (prosodyctl-action "start"))
- (stop (prosodyctl-action "stop"))))))
+ (stop (prosodyctl-action "stop"))
+ (reload (prosodyctl-action "reload"))))))
(define %prosody-accounts
(list (user-group (name "prosody") (system? #t))
--
2.12.2
C
C
Clément Lassieur wrote on 8 May 2017 08:28
[PATCH 4/4] gnu: services: dovecot: Add a 'reload' action.
(address . 26830@debbugs.gnu.org)
20170508152832.4797-4-clement@lassieur.org
* gnu/services/mail.scm (dovecot-shepherd-service): Add it.
---
gnu/services/mail.scm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Toggle diff (18 lines)
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 6305f06f8..db0772c47 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1528,7 +1528,10 @@ greyed out, instead of only later giving \"not selectable\" popup error.
"-F" "-c" #$config-file)))
(stop #~(make-forkexec-constructor
(list (string-append #$dovecot "/sbin/dovecot")
- "-c" #$config-file "stop")))))))
+ "-c" #$config-file "stop")))
+ (reload #~(make-forkexec-constructor
+ (list (string-append #$dovecot "/bin/doveadm")
+ "-c" #$config-file "reload")))))))
(define %dovecot-pam-services
(list (unix-pam-service "dovecot")))
--
2.12.2
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 26830@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 26830
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch