* bug#64365: [Shepherd] Export deregister-service.
@ 2023-06-30 14:30 Bruno Victal
2023-07-12 20:52 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Bruno Victal @ 2023-06-30 14:30 UTC (permalink / raw)
To: 64365; +Cc: ludo
Although 'register-services' is exported its counterpart
'deregister-service' is not.
Some notes:
* 'register-services' is in its plural form while its counterpart
is not, maybe one of them should be renamed for consistency sake?
* From the docstring and code the interface of 'deregister-service'
seems to differ from 'register-services' though I haven't
confirmed it. Perhaps add some documented examples for reference?
--
Furthermore, I consider that nonfree software must be eradicated.
Cheers,
Bruno.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#64365: [Shepherd] Export deregister-service.
2023-06-30 14:30 bug#64365: [Shepherd] Export deregister-service Bruno Victal
@ 2023-07-12 20:52 ` Ludovic Courtès
2023-07-13 3:10 ` Bruno Victal
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2023-07-12 20:52 UTC (permalink / raw)
To: Bruno Victal; +Cc: 64365
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
Hi,
Bruno Victal <mirai@makinata.eu> skribis:
> Although 'register-services' is exported its counterpart
> 'deregister-service' is not.
>
> Some notes:
> * 'register-services' is in its plural form while its counterpart
> is not, maybe one of them should be renamed for consistency sake?
>
> * From the docstring and code the interface of 'deregister-service'
> seems to differ from 'register-services' though I haven't
> confirmed it. Perhaps add some documented examples for reference?
All good points. Since ‘deregister-service’ is an internal helper with
a clunky interface (it takes a string, special-cases "all", prints
messages), I propose exposing ‘unregister-services’ as defined below.
WDYT?
Thanks,
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2165 bytes --]
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 6b8c562..e44cbef 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -95,6 +95,7 @@
spawn-shell-command
%precious-signals
register-services
+ unregister-services
default-respawn-limit
default-service-termination-handler
@@ -2554,6 +2555,19 @@ If it is currently stopped, replace it immediately."
(warn-deprecated-form)
(register-services services)))))
+(define (unregister-services services)
+ "Remove all of @var{services} from the registry, stopping them if they are not
+already stopped."
+ (for-each (lambda (service)
+ (unless (service-stopped? service)
+ (stop-service service)))
+ services)
+
+ ;; Remove SERVICE from the registry.
+ (put-message (current-registry-channel)
+ `(unregister ,services))
+ #t)
+
(define (deregister-service service-name)
"For each string in SERVICE-NAME, stop the associated service if
necessary and remove it from the services table. If SERVICE-NAME is
@@ -2562,13 +2576,6 @@ the special string 'all', remove all services except of 'root'.
This will remove a service either if it is identified by its canonical
name, or if it is the only service providing the service that is
requested to be removed."
- (define (deregister service)
- (when (service-running? service)
- (stop-service service))
- ;; Remove services provided by service from the hash table.
- (put-message (current-registry-channel)
- `(unregister ,(list service))))
-
(let ((name (string->symbol service-name)))
(cond ((eq? name 'all)
;; Special 'remove all' case.
@@ -2587,7 +2594,7 @@ requested to be removed."
(local-output
"Removing service '~a' providing '~a'..."
(service-canonical-name service) name))
- (deregister service)
+ (unregister-services (list service))
(local-output (l10n "Done."))))))))
(define (load-config file-name)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#64365: [Shepherd] Export deregister-service.
2023-07-12 20:52 ` Ludovic Courtès
@ 2023-07-13 3:10 ` Bruno Victal
2023-07-15 20:11 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Bruno Victal @ 2023-07-13 3:10 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 64365
Hi Ludo’,
On 2023-07-12 21:52, Ludovic Courtès wrote:
> Hi,
>
> Bruno Victal <mirai@makinata.eu> skribis:
>
>> Although 'register-services' is exported its counterpart
>> 'deregister-service' is not.
>>
>> Some notes:
>> * 'register-services' is in its plural form while its counterpart
>> is not, maybe one of them should be renamed for consistency sake?
>>
>> * From the docstring and code the interface of 'deregister-service'
>> seems to differ from 'register-services' though I haven't
>> confirmed it. Perhaps add some documented examples for reference?
>
> All good points. Since ‘deregister-service’ is an internal helper with
> a clunky interface (it takes a string, special-cases "all", prints
> messages), I propose exposing ‘unregister-services’ as defined below.
>
> WDYT?
Neat, LGTM.
--
Furthermore, I consider that nonfree software must be eradicated.
Cheers,
Bruno.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#64365: [Shepherd] Export deregister-service.
2023-07-13 3:10 ` Bruno Victal
@ 2023-07-15 20:11 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2023-07-15 20:11 UTC (permalink / raw)
To: Bruno Victal; +Cc: 64365-done
Hi Bruno,
Bruno Victal <mirai@makinata.eu> skribis:
> Neat, LGTM.
Pushed as b0eee0d037ccceb79c6db810063d129bba67f3f4.
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-15 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-30 14:30 bug#64365: [Shepherd] Export deregister-service Bruno Victal
2023-07-12 20:52 ` Ludovic Courtès
2023-07-13 3:10 ` Bruno Victal
2023-07-15 20:11 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).