Allow services to implement a 'reload' action

  • Open
  • quality assurance status badge
Details
7 participants
  • Clément Lassieur
  • Danny Milosavljevic
  • Oleg Pykhalov
  • Ludovic Courtès
  • Mathieu Othacehe
  • Maxime Devos
  • zimoun
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
M
M
Mathieu Othacehe wrote on 9 May 2017 08:37
Re: bug#26830: Allow services to implement a 'reload' action
(name . Clément Lassieur)(address . clement@lassieur.org)(address . 26830@debbugs.gnu.org)
86vapa6nyi.fsf@gmail.com
Hi Clément,

Toggle quote (7 lines)
> 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?

Your whole serie LGTM for me !

I have just one small concern, there is a already a "reload" action on
shepherd root service.

For instance you can call "herd reload root conf.scm".

Maybe it will be unclear for users how reload action differs on root
service where it takes an argument and guix services where it does not.

You could maybe mention that in the documentation and/or in the code ?

Thanks,

Mathieu
C
C
Clément Lassieur wrote on 10 May 2017 12:31
[PATCH] services: shepherd: Allow services to implement a 'reload' action.
(address . 26830@debbugs.gnu.org)
20170510193137.846-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, Shepherd Services): Update accordingly.
---
doc/guix.texi | 14 +++++++++++---
gnu/services/shepherd.scm | 9 ++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)

Toggle diff (68 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 81aa957c6..2d2015df2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8674,9 +8674,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
@@ -16204,6 +16205,13 @@ Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
G-expressions that get expanded in the Shepherd configuration file
(@pxref{G-Expressions}).
+@item @code{reload} (default: @code{#f})
+The @code{reload} field refers to the Shepherd's facilities to reload
+the service's configuration files without restarting. They are
+@code{actions} (@pxref{Slots of services,,, shepherd, The GNU Shepherd
+Manual}) and are given as G-expressions that get expanded in the
+Shepherd configuration file (@pxref{G-Expressions}).
+
@item @code{documentation}
A documentation string, as shown when running:
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 10 May 2017 12:31
Re: bug#26830: Allow services to implement a 'reload' action
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)(address . 26830@debbugs.gnu.org)
87vap8h5jl.fsf@lassieur.org
Mathieu Othacehe <m.othacehe@gmail.com> writes:

Toggle quote (9 lines)
>> 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?
>
> Your whole serie LGTM for me !

Hi Mathieu, thanks for reviewing :)

Toggle quote (8 lines)
> I have just one small concern, there is a already a "reload" action on
> shepherd root service.
>
> For instance you can call "herd reload root conf.scm".
>
> Maybe it will be unclear for users how reload action differs on root
> service where it takes an argument and guix services where it does not.

They don't differ: 'root' is just another service, as 'nginx' is. Our
'reload' action can handle many arguments as well. The only tiny
difference is that the 'root' service is implemented by Shepherd, not by
Guix.

Toggle quote (2 lines)
> You could maybe mention that in the documentation and/or in the code ?

Sure, I updated the documentation. I had forgotten the "Shepherd
Services" part and I think it helps understanding. But I didn't talk
about the 'root' service because it is a Shepherd thing and is already
described in the Shepherd manual.

WDYT?
C
C
Clément Lassieur wrote on 11 May 2017 00:13
Re: bug#26830: [PATCH] services: shepherd: Allow services to implement a 'reload' action.
(address . 26830@debbugs.gnu.org)
8760h7rhmm.fsf@lassieur.org
Clément Lassieur <clement@lassieur.org> writes:

Toggle quote (7 lines)
> +@item @code{reload} (default: @code{#f})
> +The @code{reload} field refers to the Shepherd's facilities to reload
> +the service's configuration files without restarting. They are
> +@code{actions} (@pxref{Slots of services,,, shepherd, The GNU Shepherd
> +Manual}) and are given as G-expressions that get expanded in the
> +Shepherd configuration file (@pxref{G-Expressions}).

With singular instead of plural...:

@item @code{reload} (default: @code{#f})
The @code{reload} field refers to the Shepherd's facilities to reload
the service's configuration files without restarting. It is an
@code{action} (@pxref{Slots of services,,, shepherd, The GNU Shepherd
Manual}) and is given as a G-expression that gets expanded in the
Shepherd configuration file (@pxref{G-Expressions}).
C
C
Clément Lassieur wrote on 11 May 2017 05:40
(address . 26830@debbugs.gnu.org)
87vap7sh1i.fsf@lassieur.org
Clément Lassieur <clement@lassieur.org> writes:
Toggle quote (18 lines)
> Clément Lassieur <clement@lassieur.org> writes:
>
>> +@item @code{reload} (default: @code{#f})
>> +The @code{reload} field refers to the Shepherd's facilities to reload
>> +the service's configuration files without restarting. They are
>> +@code{actions} (@pxref{Slots of services,,, shepherd, The GNU Shepherd
>> +Manual}) and are given as G-expressions that get expanded in the
>> +Shepherd configuration file (@pxref{G-Expressions}).
>
> With singular instead of plural...:
>
> @item @code{reload} (default: @code{#f})
> The @code{reload} field refers to the Shepherd's facilities to reload
> the service's configuration files without restarting. It is an
> @code{action} (@pxref{Slots of services,,, shepherd, The GNU Shepherd
> Manual}) and is given as a G-expression that gets expanded in the
> Shepherd configuration file (@pxref{G-Expressions}).

New version:

@item @code{reload} (default: @code{#f})
The @code{reload} field allows Shepherd to reload the service's
configuration files without restarting. It is an @code{action}
(@pxref{Slots of services,,, shepherd, The GNU Shepherd Manual}) and is
given as a G-expression that gets expanded in the Shepherd configuration
file (@pxref{G-Expressions}).
M
M
Mathieu Othacehe wrote on 11 May 2017 05:57
(name . Clément Lassieur)(address . clement@lassieur.org)(address . 26830@debbugs.gnu.org)
86shkbzh3d.fsf@gmail.com
Toggle quote (7 lines)
> @item @code{reload} (default: @code{#f})
> The @code{reload} field allows Shepherd to reload the service's
> configuration files without restarting. It is an @code{action}
> (@pxref{Slots of services,,, shepherd, The GNU Shepherd Manual}) and is
> given as a G-expression that gets expanded in the Shepherd configuration
> file (@pxref{G-Expressions}).

The new version looks better !

LGTM !

Mathieu
L
L
Ludovic Courtès wrote on 11 May 2017 14:24
Re: bug#26830: Allow services to implement a 'reload' action
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)
87vap7kryj.fsf@gnu.org
Hello!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

Toggle quote (9 lines)
>> 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?
>
> Your whole serie LGTM for me !

Same here, really happy to see this addressed!

Toggle quote (3 lines)
> I have just one small concern, there is a already a "reload" action on
> shepherd root service.

Right, but that’s just for ‘root’, not for the other services.

However, I think ‘reload’ might be confusing since in fact it doesn’t
load Scheme code, contrary to what “herd load root foo.scm” does (maybe
that’s what you meant?). In fact it’s closer to what “herd restart
foo” does.

What about changing the name to ‘reconfigure’ or ‘upgrade’ to avoid the
confusion?

The logical next step of this series will be to have the service upgrade
code in ‘guix system reconfigure’ invoke this action when it is defined.
That will be awesome.

Some comments:

+ #:actions (make-actions
+ (reload
+ "Reload the service's configuration files."
+ #$(shepherd-service-reload service))))))))

Here I think we should only define the action when it has a non-#f
value. That way we can distinguish between services that have a useful
reload/reconfigure/upgrade action and those that don’t; in the latter
case, we simply use ‘restart’ when upgrading.

Regarding nginx:

+ (stop (nginx-action "-s" "stop"))
+ (reload (nginx-action "-s" "reload"))))))))

Is this of any use in practice? The nginx command line is something
like:

/gnu/store/74kz9m850ycxpzkg6dvn9wbd3xjkwwrb-nginx-1.12.0/sbin/nginx -c /gnu/store/5w11ahw113fndvab3xmwcjzs2rw56sbh-nginx-config/bayfront.conf -p /var/run/nginx

and the configuration file in /gnu/store is immutable, so “nginx -s
reload” does nothing. If the action took an argument, we could do:

herd reconfigure nginx /gnu/store/…-new-config.conf

which would translate to:

nginx -s reload -c /gnu/store/…-new-config.conf

Probably our best option.

Otherwise, I think we’d have to move the config to a fixed location, say
/etc/nginx, for “nginx -s reload” to have any effect. However I don’t
quite like the use of /etc. Thoughts?

Does Dovecot have the same problem?

Thank you!

Ludo’.
L
L
Ludovic Courtès wrote on 11 May 2017 14:24
control message for bug #26830
(address . control@debbugs.gnu.org)
87tw4rkry9.fsf@gnu.org
severity 26830 important
C
C
Clément Lassieur wrote on 11 May 2017 16:08
Re: bug#26830: Allow services to implement a 'reload' action
(name . Ludovic Courtès)(address . ludo@gnu.org)
874lwrq9em.fsf@lassieur.org
Hi Ludovic,

Thanks for commenting on this :)

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (28 lines)
> Hello!
>
> Mathieu Othacehe <m.othacehe@gmail.com> skribis:
>
>>> 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?
>>
>> Your whole serie LGTM for me !
>
> Same here, really happy to see this addressed!
>
>> I have just one small concern, there is a already a "reload" action on
>> shepherd root service.
>
> Right, but that’s just for ‘root’, not for the other services.
>
> However, I think ‘reload’ might be confusing since in fact it doesn’t
> load Scheme code, contrary to what “herd load root foo.scm” does (maybe
> that’s what you meant?). In fact it’s closer to what “herd restart
> foo” does.
>
> What about changing the name to ‘reconfigure’ or ‘upgrade’ to avoid the
> confusion?

I think it's going to be even more confusing because the other init
systems (systemd, sysvinit) all call it 'reload'. And, well, people are
probably more familiar with Systemd's 'reload' than with Shepherd's
'reload root' :) WDYT?

Toggle quote (4 lines)
> The logical next step of this series will be to have the service upgrade
> code in ‘guix system reconfigure’ invoke this action when it is defined.
> That will be awesome.

Indeed!

Toggle quote (12 lines)
> Some comments:
>
> + #:actions (make-actions
> + (reload
> + "Reload the service's configuration files."
> + #$(shepherd-service-reload service))))))))
>
> Here I think we should only define the action when it has a non-#f
> value. That way we can distinguish between services that have a useful
> reload/reconfigure/upgrade action and those that don’t; in the latter
> case, we simply use ‘restart’ when upgrading.

Ok. But right now IIRC we don't even use restart after a system
reconfigure, probably because some services can't be restarted safely.
Would that be why we need a 'reload/reconfigure/upgrade' for them?

Toggle quote (13 lines)
> Regarding nginx:
>
> + (stop (nginx-action "-s" "stop"))
> + (reload (nginx-action "-s" "reload"))))))))
>
> Is this of any use in practice? The nginx command line is something
> like:
>
> /gnu/store/74kz9m850ycxpzkg6dvn9wbd3xjkwwrb-nginx-1.12.0/sbin/nginx -c /gnu/store/5w11ahw113fndvab3xmwcjzs2rw56sbh-nginx-config/bayfront.conf -p /var/run/nginx
>
> and the configuration file in /gnu/store is immutable, so “nginx -s
> reload” does nothing.

Actually, my goal was to use this after a certificate renewal. There
was going to be other patches on the certbot service as well :) And
after a certificate renewal, the names of the certificates don't change
(AFAIK they are still in /etc). So I think it would work. But indeed,
I didn't think about the main configuration file :/

Toggle quote (10 lines)
> If the action took an argument, we could do:
>
> herd reconfigure nginx /gnu/store/…-new-config.conf
>
> which would translate to:
>
> nginx -s reload -c /gnu/store/…-new-config.conf
>
> Probably our best option.

I don't see the point. If the service has already been reloaded by the
'guix system reconfigure' command (let's assume it does, but I know it
doesn't currently reload nor restart sevices...), why would a user want
to reload it again with the 'herd' command? Or maybe you want this
feature as a workaround while the 'guix system reconfigure' that reloads
services isn't implemented?

Anyway, I think the argument should be optional, so that if there are
none, the current configuration file is used. That will be useful for
certificates anyway, or for other kinds of configuration files that
aren't in the store.

Toggle quote (4 lines)
> Otherwise, I think we’d have to move the config to a fixed location, say
> /etc/nginx, for “nginx -s reload” to have any effect. However I don’t
> quite like the use of /etc. Thoughts?

I don't like it either :) 'reload' definitely has to support
configuration files that are in the store!

Toggle quote (2 lines)
> Does Dovecot have the same problem?

Yes. (But Prosody doesn't.)

Clément
L
L
Ludovic Courtès wrote on 12 May 2017 01:25
(name . Clément Lassieur)(address . clement@lassieur.org)
87inl6trbu.fsf@gnu.org
Heya,

Clément Lassieur <clement@lassieur.org> skribis:

Toggle quote (2 lines)
> Ludovic Courtès <ludo@gnu.org> writes:

[...]

Toggle quote (13 lines)
>> However, I think ‘reload’ might be confusing since in fact it doesn’t
>> load Scheme code, contrary to what “herd load root foo.scm” does (maybe
>> that’s what you meant?). In fact it’s closer to what “herd restart
>> foo” does.
>>
>> What about changing the name to ‘reconfigure’ or ‘upgrade’ to avoid the
>> confusion?
>
> I think it's going to be even more confusing because the other init
> systems (systemd, sysvinit) all call it 'reload'. And, well, people are
> probably more familiar with Systemd's 'reload' than with Shepherd's
> 'reload root' :) WDYT?

I think it’s a valid argument! However, if the choice is between
internal consistency (on the use of the word “load” in Shepherd
commands) and the rule of least surprise (choosing command names similar
to those of other programs), I would favor internal consistency, I
think. WDYT?

We have a nice bike shed to paint here. :-)

Toggle quote (15 lines)
>> Some comments:
>>
>> + #:actions (make-actions
>> + (reload
>> + "Reload the service's configuration files."
>> + #$(shepherd-service-reload service))))))))
>>
>> Here I think we should only define the action when it has a non-#f
>> value. That way we can distinguish between services that have a useful
>> reload/reconfigure/upgrade action and those that don’t; in the latter
>> case, we simply use ‘restart’ when upgrading.
>
> Ok. But right now IIRC we don't even use restart after a system
> reconfigure, probably because some services can't be restarted safely.

Currently ‘guix system reconfigure’ (specifically
‘upgrade-shepherd-services’) reloads and starts all services that are
currently stopped, on the grounds that it would not be safe/desirable to
simply stop any running service.

Toggle quote (2 lines)
> Would that be why we need a 'reload/reconfigure/upgrade' for them?

‘upgrade-shepherd-services’ could check whether a service has an
‘upgrade’ action. If it does, it could call that action unconditionally
since that action would semantically have the same effect has
stop/unload/load/start, except that it does that “live”, without
stopping anything.

Toggle quote (18 lines)
>> Regarding nginx:
>>
>> + (stop (nginx-action "-s" "stop"))
>> + (reload (nginx-action "-s" "reload"))))))))
>>
>> Is this of any use in practice? The nginx command line is something
>> like:
>>
>> /gnu/store/74kz9m850ycxpzkg6dvn9wbd3xjkwwrb-nginx-1.12.0/sbin/nginx -c /gnu/store/5w11ahw113fndvab3xmwcjzs2rw56sbh-nginx-config/bayfront.conf -p /var/run/nginx
>>
>> and the configuration file in /gnu/store is immutable, so “nginx -s
>> reload” does nothing.
>
> Actually, my goal was to use this after a certificate renewal. There
> was going to be other patches on the certbot service as well :) And
> after a certificate renewal, the names of the certificates don't change
> (AFAIK they are still in /etc).

Indeed.

Toggle quote (3 lines)
> So I think it would work. But indeed, I didn't think about the main
> configuration file :/

Yeah. Sorry for dropping a fly in the ointment. :-/

Toggle quote (17 lines)
>> If the action took an argument, we could do:
>>
>> herd reconfigure nginx /gnu/store/…-new-config.conf
>>
>> which would translate to:
>>
>> nginx -s reload -c /gnu/store/…-new-config.conf
>>
>> Probably our best option.
>
> I don't see the point. If the service has already been reloaded by the
> 'guix system reconfigure' command (let's assume it does, but I know it
> doesn't currently reload nor restart sevices...), why would a user want
> to reload it again with the 'herd' command? Or maybe you want this
> feature as a workaround while the 'guix system reconfigure' that reloads
> services isn't implemented?

Sorry, I wasn’t clear. Action can take arguments; most don’t, but some
do (like ‘herd start cow-store /mnt’ when installing GuixSD.) What I’m
suggesting here is to add one/several arguments to this reload/upgrade
action. The meaning of these arguments would be defined by the service
itself.

For nginx, there could be one argument (the config file) or two (the
config file and the nginx executable file name). The reload/upgrade
action would do “nginx -s reload -c …” and so on.

The ‘upgrade-shepherd-services’ procedure would automatically call the
reload/upgrade action with the right arguments. For that, it needs to
know what the arguments are. An option would be to add an
‘upgrade-arguments’ field to <shepherd-service> that would return the
arguments to pass to the upgrade action.

Does that make sense?

Toggle quote (5 lines)
> Anyway, I think the argument should be optional, so that if there are
> none, the current configuration file is used. That will be useful for
> certificates anyway, or for other kinds of configuration files that
> aren't in the store.

We could do that too. My thought was that the primary consumer of this
action would be ‘guix system reconfigure’ and not the user.

Thanks,
Ludo’.
C
C
Clément Lassieur wrote on 12 May 2017 01:57
(name . Ludovic Courtès)(address . ludo@gnu.org)
871sruqwok.fsf@lassieur.org
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (27 lines)
> Heya,
>
> Clément Lassieur <clement@lassieur.org> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>
> [...]
>
>>> However, I think ‘reload’ might be confusing since in fact it doesn’t
>>> load Scheme code, contrary to what “herd load root foo.scm” does (maybe
>>> that’s what you meant?). In fact it’s closer to what “herd restart
>>> foo” does.
>>>
>>> What about changing the name to ‘reconfigure’ or ‘upgrade’ to avoid the
>>> confusion?
>>
>> I think it's going to be even more confusing because the other init
>> systems (systemd, sysvinit) all call it 'reload'. And, well, people are
>> probably more familiar with Systemd's 'reload' than with Shepherd's
>> 'reload root' :) WDYT?
>
> I think it’s a valid argument! However, if the choice is between
> internal consistency (on the use of the word “load” in Shepherd
> commands) and the rule of least surprise (choosing command names similar
> to those of other programs), I would favor internal consistency, I
> think. WDYT?

Ok! I like 'upgrade'.

Toggle quote (35 lines)
>>> If the action took an argument, we could do:
>>>
>>> herd reconfigure nginx /gnu/store/…-new-config.conf
>>>
>>> which would translate to:
>>>
>>> nginx -s reload -c /gnu/store/…-new-config.conf
>>>
>>> Probably our best option.
>>
>> I don't see the point. If the service has already been reloaded by the
>> 'guix system reconfigure' command (let's assume it does, but I know it
>> doesn't currently reload nor restart sevices...), why would a user want
>> to reload it again with the 'herd' command? Or maybe you want this
>> feature as a workaround while the 'guix system reconfigure' that reloads
>> services isn't implemented?
>
> Sorry, I wasn’t clear. Action can take arguments; most don’t, but some
> do (like ‘herd start cow-store /mnt’ when installing GuixSD.) What I’m
> suggesting here is to add one/several arguments to this reload/upgrade
> action. The meaning of these arguments would be defined by the service
> itself.
>
> For nginx, there could be one argument (the config file) or two (the
> config file and the nginx executable file name). The reload/upgrade
> action would do “nginx -s reload -c …” and so on.
>
> The ‘upgrade-shepherd-services’ procedure would automatically call the
> reload/upgrade action with the right arguments. For that, it needs to
> know what the arguments are. An option would be to add an
> ‘upgrade-arguments’ field to <shepherd-service> that would return the
> arguments to pass to the upgrade action.
>
> Does that make sense?

Yes! Thank you :)
D
D
Danny Milosavljevic wrote on 28 Jan 2018 12:34
(name . Clément Lassieur)(address . clement@lassieur.org)
20180128213430.33175f51@scratchpost.org
Any news on this reload action patchset?
C
C
Clément Lassieur wrote on 28 Jan 2018 15:23
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87inbl4lgh.fsf@lassieur.org
Danny Milosavljevic <dannym@scratchpost.org> writes:

Toggle quote (2 lines)
> Any news on this reload action patchset?

I didn't find time to work on it. It's still on my todo list but if
anyone wants to do it, please go ahead.
L
L
Ludovic Courtès wrote on 11 Jul 2018 15:00
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)
87bmbdigbj.fsf@gnu.org
Hello!

ludo@gnu.org (Ludovic Courtès) skribis:

Toggle quote (35 lines)
> The logical next step of this series will be to have the service upgrade
> code in ‘guix system reconfigure’ invoke this action when it is defined.
> That will be awesome.
>
> Some comments:
>
> + #:actions (make-actions
> + (reload
> + "Reload the service's configuration files."
> + #$(shepherd-service-reload service))))))))
>
> Here I think we should only define the action when it has a non-#f
> value. That way we can distinguish between services that have a useful
> reload/reconfigure/upgrade action and those that don’t; in the latter
> case, we simply use ‘restart’ when upgrading.
>
> Regarding nginx:
>
> + (stop (nginx-action "-s" "stop"))
> + (reload (nginx-action "-s" "reload"))))))))
>
> Is this of any use in practice? The nginx command line is something
> like:
>
> /gnu/store/74kz9m850ycxpzkg6dvn9wbd3xjkwwrb-nginx-1.12.0/sbin/nginx -c /gnu/store/5w11ahw113fndvab3xmwcjzs2rw56sbh-nginx-config/bayfront.conf -p /var/run/nginx
>
> and the configuration file in /gnu/store is immutable, so “nginx -s
> reload” does nothing. If the action took an argument, we could do:
>
> herd reconfigure nginx /gnu/store/…-new-config.conf
>
> which would translate to:
>
> nginx -s reload -c /gnu/store/…-new-config.conf

FWIW, with the patch at https://bugs.gnu.org/32128, adding such
actions becomes easy (it’s a generalization of what you did in this
patch series.)

Ludo’.
C
C
Clément Lassieur wrote on 12 Jul 2018 06:06
Re: [bug#26830] Allow services to implement a 'reload' action
(name . Ludovic Courtès)(address . ludo@gnu.org)
874lh438oj.fsf@lassieur.org
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (6 lines)
> FWIW, with the patch at https://bugs.gnu.org/32128, adding such
> actions becomes easy (it’s a generalization of what you did in this
> patch series.)
>
> Ludo’.

Hehe thanks for the reminder, I'll consider working on this again soon
:-)

Clément
Z
Z
zimoun wrote on 23 Mar 2022 05:56
Re: bug#26830: Allow services to implement a 'reload' action
(name . Ludovic Courtès)(address . ludo@gnu.org)
86lex0zv27.fsf_-_@gmail.com
Hi,

This old patch [1] is… old! :-)



On Thu, 12 Jul 2018 at 00:00, ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (4 lines)
> FWIW, with the patch at https://bugs.gnu.org/32128, adding such
> actions becomes easy (it’s a generalization of what you did in this
> patch series.)

Considering this merged #32128 [1]:

Toggle snippet (3 lines)
Done in Shepherd commit 5ab8cbc9bcfce586a5389ad95a65f011d02bd289.



What is then the status of this patch adding ’upgrade’? Does it still
make sense?


Cheers,
simon
L
L
Ludovic Courtès wrote on 24 Mar 2022 01:41
(name . zimoun)(address . zimon.toutoune@gmail.com)
87wngjeo8l.fsf@gnu.org
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

Toggle quote (3 lines)
> What is then the status of this patch adding ’upgrade’? Does it still
> make sense?

I think having ‘reload’ actions for nginx, dovecot, etc. whereby the
daemon reloads its config without stopping still makes sense.

I wonder if the patch as-is would achieve that though, because in
general those daemons are run with ‘-c /gnu/store/…-config’, so
reloading would just reload the same file.

Ludo’.
O
O
Oleg Pykhalov wrote on 24 Mar 2022 06:52
Re: [bug#26830] Allow services to implement a 'reload' action
(name . Ludovic Courtès)(address . ludo@gnu.org)
87lewztq2t.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

[…]

Toggle quote (4 lines)
> I wonder if the patch as-is would achieve that though, because in
> general those daemons are run with ‘-c /gnu/store/…-config’, so
> reloading would just reload the same file.

Maybe we could switch to another practice in service definitions:

‘/gnu/store/...-some-program/bin/some-program -c /etc/some-config’

$ ls -l /etc/static
/etc/static -> /gnu/store/...-etc/etc

$ ls -l /etc/some-config
/etc/some-config -> /etc/static/some-config
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmI8d7oUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+px7fA/+MWua88mLyrEXsZeoyXDcVLkRmSO6
nOyXrevrVke/1f0N8w/pTr2JiMLAd9Ao1Rfk2LeBdd/gd90M2nBy6494xeT2ADkD
4UxnJel2ZHEh0lEHFjLZnoB5AHc+kRNDWWZBEW1PBg0sGl4mkWOYVdsYnffGnBLd
LWqjrGu0LZA7KXkU8kD0luTAJgmU4EVu3oFAxBuG8kxk4dNgcXsC7bUHYgaKpgJS
MPC4ai57x2qHICbkXV4HJ5W5dJXxdntF+2SyXKykzP1adOEEDWOB9YAEOqWoRbSP
i6lG1Gkc0FrtuCcJiA2fWKl5IviKxjSvm6LmZcN8kuqZTW9j3jzWANU6z7BxHU5V
YqCyBpHluk3b1oegJWteGINLd6kjyuDCIYE/7YCb2mxPiWK+Ql0d7M6EZB2MPzsh
vN3QXjOlUbI12LGS4L0rMXPSxL01N21NVbzEZRB8WZQldwYR2FvCXUF7oEQrpeb1
OGDxutGJdHwYI/sFvwX1ksqmyD+XnTkc/4RdA81xFnvPmChuN6HythR7xi+w0A0g
Z5HkJlbFCURbuzAzip4b3a7QGNHwgsNEabUj+mTIDVHVETYMVryeIfOxjOwUWmnn
BhEHIK4i61IfUUFnpM+WSzyg1THRCO1+GyqRPH8cJYf/6GWMXI9PHsDGVWEMX7oG
YBaJ2jiC9BToe3A=
=xZPV
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 26 Mar 2022 13:46
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
87v8w07886.fsf@gnu.org
Hi,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (18 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
> […]
>
>> I wonder if the patch as-is would achieve that though, because in
>> general those daemons are run with ‘-c /gnu/store/…-config’, so
>> reloading would just reload the same file.
>
> Maybe we could switch to another practice in service definitions:
>
> ‘/gnu/store/...-some-program/bin/some-program -c /etc/some-config’
>
> $ ls -l /etc/static
> /etc/static -> /gnu/store/...-etc/etc
>
> $ ls -l /etc/some-config
> /etc/some-config -> /etc/static/some-config

Hmm yes, we could (I think Maxim did that recently for a service, I
forgot which one.)

I like the clarity of ‘-c /gnu/store/…-config’ better than the ambient
authority and ambiguity of ‘/etc/config’, but I guess we have to made a
tradeoff.

Ludo’.
M
M
Maxime Devos wrote on 26 Mar 2022 14:14
aab93ecb0ca047cbb1012d066d37ac596333962b.camel@telenet.be
Ludovic Courtès schreef op za 26-03-2022 om 21:46 [+0100]:
Toggle quote (4 lines)
> I like the clarity of ‘-c /gnu/store/…-config’ better than the ambient
> authority and ambiguity of ‘/etc/config’, but I guess we have to made a
> tradeoff.

How about something in-between:

/run/current-system/SOME-SUBDIRECTORY/etc/config

That way, there is less potential for non-atomicity problems caused by
individual files in /etc/...

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYj+CLRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lknAP9/di8O11tSGJU6qInvix7ClEyY
JlC7zAZlytKPFroQrwD8CkTXtOs8WMAAglFDktyeG1dyBDaoeFAg1Wl0vrCEjwU=
=i+Ac
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 29 Mar 2022 06:36
(name . Maxime Devos)(address . maximedevos@telenet.be)
87k0ccyj6n.fsf@gnu.org
Maxime Devos <maximedevos@telenet.be> skribis:

Toggle quote (9 lines)
> Ludovic Courtès schreef op za 26-03-2022 om 21:46 [+0100]:
>> I like the clarity of ‘-c /gnu/store/…-config’ better than the ambient
>> authority and ambiguity of ‘/etc/config’, but I guess we have to made a
>> tradeoff.
>
> How about something in-between:
>
> /run/current-system/SOME-SUBDIRECTORY/etc/config

It’s “ambient authority” in the same way as /etc.

Ludo’.
?
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