[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/03: service: Remove support for the 'unknown' service.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/03: service: Remove support for the 'unknown' service. |
Date: |
Sun, 26 Feb 2023 16:40:49 -0500 (EST) |
civodul pushed a commit to branch master
in repository shepherd.
commit 2afe1feeee4f2b23e9fa70bb8462b59d37f34f72
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Feb 25 23:16:24 2023 +0100
service: Remove support for the 'unknown' service.
This feature was untested and there were no clear use cases.
* modules/shepherd/service.scm (launch-service, stop, action): Remove
lookup of the 'unknown' service.
(handle-unknown): Remove.
* doc/shepherd.texi (The root and unknown services): Rename to...
(The root Service): ... this. Remove paragraph about the 'unknown'
service.
---
doc/shepherd.texi | 18 +++-----------
modules/shepherd/service.scm | 58 ++++++--------------------------------------
2 files changed, 12 insertions(+), 64 deletions(-)
diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index b4275e6..2224ee0 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -499,7 +499,7 @@ It causes the @var{action} of the @var{service} to be
invoked. When
@code{detailed-status}, the @code{root} service is used@footnote{This
shorthand does not work for other actions such as @code{stop}, because
inadvertently typing @code{herd stop} would stop all the services, which
-could be pretty annoying.} (@pxref{The root and unknown services}, for
+could be pretty annoying.} (@pxref{The root Service}, for
more information on the @code{root} service.)
For each action, you should pass the appropriate @var{arg}s. Actions
@@ -606,7 +606,7 @@ defined in the @code{(shepherd service)} module.
stopping services.
* Service Examples:: Examples that show how services are used.
* Managing User Services:: Running the Shepherd as a user.
-* The root and unknown services:: Special services in the Shepherd.
+* The root Service:: The service that comes first.
@end menu
@c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -1369,8 +1369,8 @@ Then, individual user services can be put in
@c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-@node The root and unknown services
-@section The @code{root} and @code{unknown} services
+@node The root Service
+@section The @code{root} Service
@cindex root service
@cindex special services
@@ -1425,16 +1425,6 @@ respawnable services are started, as otherwise we would
not get the
@end table
-@cindex unknown service
-@cindex fallback service
-The @code{unknown} service must be defined by the user and if it
-exists, is used as a fallback whenever we try to invoke an unknown
-action of an existing service or use a service that does not exist.
-This is useful only in few cases, but enables you to do various sorts
-of unusual things.
-
-@c FIXME-CRITICAL: finish
-
@c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@node Misc Facilities
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 4a4824a..2c171d0 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -87,7 +87,6 @@
register-services
provided-by
required-by
- handle-unknown
default-service-termination-handler
default-environment-variables
@@ -990,14 +989,7 @@ Used by `start' and `enforce'."
;; None running yet, start one.
(find (lambda (service)
(apply proc service args))
- possibilities)
-
- ;; Failed to start something, try the 'unknown' service.
- (let ((unknown (lookup-running 'unknown)))
- (if (and unknown
- (defines-action? unknown 'start))
- (apply action unknown 'start name args)
- #f))))))
+ possibilities)))))
;; Starting by name.
(define-method (start (obj <symbol>) . args)
@@ -1012,27 +1004,19 @@ Used by `start' and `enforce'."
(let ((which (find (negate stopped?) (lookup-services obj))))
(if which
(apply stop which args)
- (let ((unknown (lookup-running 'unknown)))
- (if (and unknown
- (defines-action? unknown 'stop))
- (apply action unknown 'stop obj args)
- ;; Only print an error if the service does not exist.
- (match (lookup-services obj)
- (()
- (raise (condition (&missing-service-error (name obj)))))
- ((stopped . _)
- (list))))))))
+ ;; Only print an error if the service does not exist.
+ (match (lookup-services obj)
+ (()
+ (raise (condition (&missing-service-error (name obj)))))
+ ((stopped . _)
+ (list))))))
(define-method (action (obj <symbol>) the-action . args)
"Perform THE-ACTION on all the services named OBJ. Return the list of
results."
(let ((which-services (lookup-running-or-providing obj)))
(if (null? which-services)
- (let ((unknown (lookup-running 'unknown)))
- (if (and unknown
- (defines-action? unknown 'action))
- (apply action unknown 'action the-action args)
- (raise (condition (&missing-service-error (name obj))))))
+ (raise (condition (&missing-service-error (name obj))))
(map (lambda (service)
(apply action service the-action args))
which-services))))
@@ -1067,32 +1051,6 @@ background:~{ ~a~}."
-;; Handling of unprovided service-symbols. This can be called in
-;; either of the following ways (i.e. with either three or four
-;; arguments):
-;; handle-unknown SERVICE-SYMBOL [ 'start | 'stop ] ARGS
-;; handle-unknown SERVICE-SYMBOL 'action THE_ACTION ARGS
-(define (handle-unknown . args)
- (let ((unknown (lookup-running 'unknown)))
- ;; FIXME: Display message if no unknown service.
- (when unknown
- (apply (case-lambda
- ;; Start or stop.
- ((service-symbol start/stop args)
- (if (defines-action? unknown start/stop)
- (apply action unknown start/stop service-symbol args)
- ;; FIXME: Bad message.
- (local-output "Cannot ~a ~a." start/stop service-symbol)))
- ;; Action.
- ((service-symbol action-sym the-action args)
- (assert (eq? action-sym 'action))
- (if (defines-action? unknown 'action)
- (apply action unknown 'action service-symbol
- the-action args)
- (local-output (l10n "No service provides ~a.")
- service-symbol))))
- args))))
-
;; Check if any of SERVICES is running. If this is the case, return
;; it. If none, return `#f'. Only the first one found will be
;; returned; this is because this is mainly intended to be applied on