guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 05/05: Rename 'dmd' service to 'root'.


From: Ludovic Courtès
Subject: [shepherd] 05/05: Rename 'dmd' service to 'root'.
Date: Sun, 24 Jan 2016 21:09:30 +0000

civodul pushed a commit to branch master
in repository shepherd.

commit cddf6a5aed5c66f91b93a84afa4b5dadde743b13
Author: Alex Kost <address@hidden>
Date:   Sun Jan 24 18:33:11 2016 +0300

    Rename 'dmd' service to 'root'.
    
    * modules/shepherd/service.scm (dmd-service): Rename to...
    (shepherd-service): ... this.  Provide both 'root' and 'shepherd' names.
    Adjust the rest file accordingly.
    * modules/shepherd.scm: Likewise.
    * modules/herd.scm: Likewise.
    * modules/halt.scm: Likewise.
    * modules/reboot.scm: Likewise.
    * modules/shepherd/support.scm (make-bare-init-file): Likewise.
    * shepherd.texi: Likewise.
    * tests/basic.sh: Likewise.
    * tests/no-home.sh: Likewise.
    * tests/status-sexp.sh: Likewise.
    
    Signed-off-by: Ludovic Courtès <address@hidden>
---
 modules/herd.scm             |   12 +++++---
 modules/shepherd.scm         |   10 +++---
 modules/shepherd/service.scm |   46 +++++++++++++++++-----------------
 modules/shepherd/support.scm |    4 +-
 shepherd.texi                |   57 +++++++++++++++++++++--------------------
 tests/basic.sh               |   28 ++++++++++----------
 tests/no-home.sh             |    4 +-
 tests/respawn.sh             |    2 +-
 tests/status-sexp.sh         |   19 +++++++------
 9 files changed, 93 insertions(+), 89 deletions(-)

diff --git a/modules/herd.scm b/modules/herd.scm
index c2cca85..a5e6c16 100644
--- a/modules/herd.scm
+++ b/modules/herd.scm
@@ -88,7 +88,8 @@ of pairs."
 the daemon via SOCKET-FILE."
   (with-system-error-handling
    (let ((sock    (open-connection socket-file))
-         (action* (if (and (eq? service 'dmd) (eq? action 'detailed-status))
+         (action* (if (and (eq? action 'detailed-status)
+                           (memq service '(root shepherd)))
                       'status
                       action)))
      ;; Send the command.
@@ -110,9 +111,9 @@ the daemon via SOCKET-FILE."
 
         ;; Then interpret the result
         (match (list action service)
-          (('status 'dmd)
+          (('status (or 'root 'shepherd))
            (display-status-summary (first result)))
-          (('detailed-status 'dmd)
+          (('detailed-status (or 'root 'shepherd))
            (display-detailed-status (first result)))
           (('status _)
            ;; We get a list of statuses, in case several services have the
@@ -135,7 +136,8 @@ the daemon via SOCKET-FILE."
        ((? eof-object?)
         ;; When stopping shepherd, we may get an EOF in lieu of a real reply,
         ;; and that's fine.  In other cases, a premature EOF is an error.
-        (unless (and (eq? action 'stop) (eq? service 'dmd))
+        (unless (and (eq? action 'stop)
+                     (memq service '(root shepherd)))
           (report-error (l10n "premature end-of-file while \
 talking to shepherd"))
           (exit 1))))
@@ -167,7 +169,7 @@ talking to shepherd"))
 
       (match (reverse command-args)
         (((and action (or "status" "detailed-status"))) ;one argument
-         (run-command socket-file (string->symbol action) 'dmd '()))
+         (run-command socket-file (string->symbol action) 'root '()))
         ((action service args ...)
          (run-command socket-file
                       (string->symbol action)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index ce24513..5e26b4f 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -140,8 +140,8 @@
     ;; Send output to log and clients.
     (set-current-output-port shepherd-output-port)
 
-    ;; Start the dmd service.
-    (start dmd-service)
+    ;; Start the 'root' service.
+    (start root-service)
     ;; This _must_ succeed.  (We could also put the `catch' around
     ;; `main', but it is often useful to get the backtrace, and
     ;; `caught-error' does not do this yet.)
@@ -175,7 +175,7 @@
     ;; ctrlaltdel(8).
     (sigaction SIGINT
       (lambda _
-        (stop dmd-service)))
+        (stop root-service)))
 
     ;; Ignore SIGPIPE so that we don't die if a client closes the connection
     ;; prematurely.
@@ -267,7 +267,7 @@
                           port))))
        (lambda (key)
          ;; Most likely we're receiving 'quit' from the 'stop' method of
-         ;; DMD-SERVICE.  So, if we're running as 'root', just reboot.
+         ;; ROOT-SERVICE.  So, if we're running as 'root', just reboot.
          (if (zero? (getuid))
              (begin
                (local-output "Rebooting...")
@@ -283,7 +283,7 @@ would write them on the 'herd' command line."
     (if (eof-object? line)
 
         ;; Exit on `C-d'.
-        (stop dmd-service)
+        (stop root-service)
 
         (begin
           (match (string-tokenize line)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index fd9c7e2..1c280aa 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -70,7 +70,7 @@
             make-system-destructor
             make-init.d-service
 
-            dmd-service
+            root-service
             make-actions
 
             &service-error
@@ -344,8 +344,8 @@ wire."
                           (slot-ref obj 'running)
                           args))
                  (lambda (key . args)
-                   ;; Special case: `dmd' may quit.
-                   (and (eq? dmd-service obj)
+                   ;; Special case: 'root' may quit.
+                   (and (eq? root-service obj)
                         (eq? key 'quit)
                         (apply quit args))
                    (caught-error key args)))
@@ -405,8 +405,8 @@ wire."
              (lambda ()
                (apply proc (slot-ref obj 'running) args))
              (lambda (key . args)
-               ;; Special case: `dmd' may quit.
-               (and (eq? dmd-service obj)
+               ;; Special case: 'root' may quit.
+               (and (eq? root-service obj)
                     (eq? key 'quit)
                     (apply quit args))
                (report-exception the-action obj key args)))))))
@@ -441,7 +441,7 @@ wire."
                     (action-list obj)))
       (else
        ;; FIXME: Implement doc-help.
-       (local-output "Unknown keyword.  Try `doc dmd help'.")))))
+       (local-output "Unknown keyword.  Try 'doc root help'.")))))
 
 ;; Return a list of canonical names of the services that conflict with
 ;; OBJ.
@@ -947,7 +947,7 @@ otherwise by updating its state."
 (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
-the special string 'all', remove all services except for dmd.
+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
@@ -978,7 +978,7 @@ requested to be removed."
                (match value
                  ((service)     ; only one service associated with KEY
                   (and (eq? key (canonical-name service))
-                       (not (eq? key 'dmd))
+                       (not (memq key '(root shepherd)))
                        (cons key service)))
                  (_ #f)))               ; all other cases: #f.
              %services)))
@@ -1029,7 +1029,7 @@ requested to be removed."
 
 
 
-;; The `dmd' service.
+;; The 'root' service.
 
 (define (shutdown-services)
   "Shut down all the currently running services; update the persistent state
@@ -1049,10 +1049,10 @@ file when persistence is enabled."
         (lambda (p)
           (format p "~{~a ~}~%" running-services))))))
 
-(define dmd-service
+(define root-service
   (make <service>
-    #:docstring "The dmd service is used to operate on dmd itself."
-    #:provides '(dmd)
+    #:docstring "The root service is used to operate on shepherd itself."
+    #:provides '(root shepherd)
     #:requires '()
     #:respawn #f
     #:start (lambda args
@@ -1060,9 +1060,9 @@ file when persistence is enabled."
                 (display-version))
              #t)
     #:stop (lambda (unused . args)
-            (local-output "Exiting dmd...")
+            (local-output "Exiting shepherd...")
             ;; Prevent that we try to stop ourself again.
-            (slot-set! dmd-service 'running #f)
+            (slot-set! root-service 'running #f)
              (shutdown-services)
             (quit))
     ;; All actions here need to take care that they do not invoke any
@@ -1082,7 +1082,7 @@ Clients such as 'herd' can read it and format it in a 
human-readable way."
       "Halt the system."
       (lambda (running)
         (catch 'quit
-          (cut stop dmd-service)
+          (cut stop root-service)
           (lambda (key)
             (local-output "Halting...")
             (halt)))))
@@ -1091,25 +1091,25 @@ Clients such as 'herd' can read it and format it in a 
human-readable way."
       "Halt the system and turn it off."
       (lambda (running)
         (catch 'quit
-          (cut stop dmd-service)
+          (cut stop root-service)
           (lambda (key)
             (local-output "Shutting down...")
             (power-off)))))
      ;; Load a configuration file.
      (load
-      "Load the Scheme code from FILE into dmd.  This is potentially
+      "Load the Scheme code from FILE into shepherd.  This is potentially
 dangerous.  You have been warned."
       (lambda (running file-name)
         (load-config file-name)))
      ;; Unload a service
      (unload
       "Unload the service identified by SERVICE-NAME or all services
-except for dmd if SERVICE-NAME is 'all'.  Stop services before
+except for 'root' if SERVICE-NAME is 'all'.  Stop services before
 removing them if needed."
       (lambda (running service-name)
         (deregister-service service-name)))
      (reload
-      "Unload all services, then load from FILE-NAME into dmd.  This
+      "Unload all services, then load from FILE-NAME into shepherd.  This
 is potentialy dangerous.  You have been warned."
       (lambda (running file-name)
         (and (deregister-service "all") ; unload all services
@@ -1117,7 +1117,7 @@ is potentialy dangerous.  You have been warned."
      ;; Go into the background.
      (daemonize
       "Go into the background.  Be careful, this means that a new
-process will be created, so dmd will not get SIGCHLD signals anymore
+process will be created, so shepherd will not get SIGCHLD signals anymore
 if previously spawned childs terminate.  Therefore, this action should
 usually only be used (if at all) *before* childs get spawned for which
 we want to receive these signals."
@@ -1143,7 +1143,7 @@ name as argument that will be used to store the status."
       (lambda (running)
        (set! persistency #f)))
      (cd
-      "Change the working directory of dmd.  This only makes sense
+      "Change the working directory of shepherd.  This only makes sense
 when in interactive mode, i.e. with `--socket=none'."
       (lambda (running dir)
        (chdir dir)))
@@ -1151,8 +1151,8 @@ when in interactive mode, i.e. with `--socket=none'."
      ;; we're better off by implementing it due to the
      ;; default action.
      (restart
-      "This does not work for dmd."
+      "This does not work for the 'root' service."
       (lambda (running)
        (local-output "You must be kidding."))))))
 
-(register-services dmd-service)
+(register-services root-service)
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index fbc7b3a..9bfb050 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -247,8 +247,8 @@ TARGET should be a string representing a filepath + name."
 ;; providing them as arguments to 'register-services'.
 ""(register-services)
 
-;; Send dmd into the background
-""(action 'dmd 'daemonize)
+;; Send shepherd into the background
+""(action 'shepherd 'daemonize)
 
 ;; Services to start when dmd starts:
 ;; Add the name of each service that should be started to the list
diff --git a/shepherd.texi b/shepherd.texi
index 105155f..ef1d9da 100644
--- a/shepherd.texi
+++ b/shepherd.texi
@@ -278,19 +278,19 @@ of the additional actions a service provides; obviously, 
it can also
 be called when the service is not running.  Services cannot provide
 their own implementation of @code{list-actions}.
 
-A special service is @code{dmd}, which is used for controlling the Shepherd
-itself.  It implements various actions.  For example, the
address@hidden action displays which services are started and which
-ones are stopped, whereas @code{detailed-status} has the effect of
-applying the default implementation of @code{status} to all services
-one after another.  The @code{load}
-action is unusual insofar as it shows a feature that is actually
-available to all services, but which we have not seen yet: It takes an
-additional argument.  You can use @code{load} to load arbitrary code
-into the Shepherd at runtime, like this:
+A special service is @code{root}, which is used for controlling the
+Shepherd itself.  You can also reference to this service as
address@hidden  It implements various actions.  For example, the
address@hidden action displays which services are started and which ones
+are stopped, whereas @code{detailed-status} has the effect of applying
+the default implementation of @code{status} to all services one after
+another.  The @code{load} action is unusual insofar as it shows a
+feature that is actually available to all services, but which we have
+not seen yet: It takes an additional argument.  You can use @code{load}
+to load arbitrary code into the Shepherd at runtime, like this:
 
 @example
-herd load dmd ~/additional-services.scm
+herd load shepherd ~/additional-services.scm
 @end example
 
 This is enough now about the @command{herd} and @command{shepherd} programs, we
@@ -322,7 +322,8 @@ You can display the status of a service, even if the 
service does not
 provide a specific implementation for this action.  The same is true
 for restarting.
 @item
-The @code{dmd} service is used to control @command{shepherd} itself.
+The @code{root}/@code{shepherd} service is used to control
address@hidden itself.
 @end itemize
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -446,11 +447,11 @@ herd address@hidden@dots{}] @var{action} address@hidden 
address@hidden@dots{}]]
 
 It causes the @var{action} of the @var{service} to be invoked.  When
 @var{service} is omitted and @var{action} is @code{status} or
address@hidden, the @code{dmd} service is address@hidden
address@hidden, the @code{root} service is address@hidden
 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 dmd and unknown services}, for
-more information on the @code{dmd} service.)
+could be pretty annoying.} (@pxref{The root and unknown services}, for
+more information on the @code{root} service.)
 
 For each action, you should pass the appropriate @var{arg}s.  Actions
 that are available for every service are @code{start}, @code{stop},
@@ -492,8 +493,8 @@ reboot the system.  It has the following synopsis:
 reboot address@hidden@dots{}]
 @end example
 
-It is equivalent to running @command{herd stop dmd}.  The @code{reboot}
-command understands the following option:
+It is equivalent to running @command{herd stop shepherd}.  The
address@hidden command understands the following option:
 
 @table @samp
 
@@ -518,8 +519,8 @@ off the system.  It has the following synopsis:
 halt address@hidden@dots{}]
 @end example
 
-It is equivalent to running @command{herd power-off dmd}.  As usual, the
address@hidden command understands the following option:
+It is equivalent to running @command{herd power-off shepherd}.  As
+usual, the @code{halt} command understands the following option:
 
 @table @samp
 
@@ -555,7 +556,7 @@ defined in the @code{(shepherd service)} module.
 * Service De- and Constructors:: Commonly used ways of starting and
                                    stopping services.
 * Service Examples::             Examples that show how services are used.
-* The dmd and unknown services:: Special services in the Shepherd.
+* The root and unknown services:: Special services in the Shepherd.
 @end menu
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -749,7 +750,7 @@ terminates.
 Display status information about @var{obj}.  This method is called
 when the user performs the action @code{status} on @var{obj}, but
 there is no specific implementation given for it.  It is also called
-when @code{detailed-status} is applied on @code{dmd}.
+when @code{detailed-status} is applied on the @code{root} service.
 @end deffn
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -917,15 +918,15 @@ also specifies some more initial values for the slots:
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
address@hidden The dmd and unknown services
address@hidden The @code{dmd} and @code{unknown} services
address@hidden The root and unknown services
address@hidden The @code{root} and @code{unknown} services
 
address@hidden dmd service
address@hidden root service
 @cindex special services
-The service @code{dmd} is special, because it is used to control the Shepherd
-itself.  It provides the following actions (in addition to
address@hidden, @code{disable} and @code{restart} which do not make
-sense here).
+The service @code{root} is special, because it is used to control the
+Shepherd itself.  It has an alias @code{shepherd}.  It provides the
+following actions (in addition to @code{enable}, @code{disable} and
address@hidden which do not make sense here).
 
 @table @code
 @item status
diff --git a/tests/basic.sh b/tests/basic.sh
index 462f8ad..a20e9dc 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -67,8 +67,8 @@ dmd_pid="`cat $pid`"
 
 kill -0 $dmd_pid
 test -S "$socket"
-pristine_status=`$herd status dmd` # Prep for 'reload' test.
-echo $pristine_status | grep -E '(Start.*dmd|Stop.*test)'
+pristine_status=`$herd status root` # Prep for 'reload' test.
+echo $pristine_status | grep -E '(Start.*root|Stop.*test)'
 
 $herd start test
 test -f "$stamp"
@@ -97,35 +97,35 @@ do
     $herd $action does-not-exist 2>&1 | grep "does-not-exist.*not.*found"
 done
 
-if $herd an-action-that-does-not-exist dmd
+if $herd an-action-that-does-not-exist root
 then false; else true; fi
 
 # Wrong number of arguments for an action.
-if $herd status dmd foo bar baz;
+if $herd status root foo bar baz;
 then false; else true; fi
 
 # Asking for the doc of specific actions.
-$herd doc dmd action status
-if $herd doc dmd action an-action-that-does-not-exist
+$herd doc root action status
+if $herd doc root action an-action-that-does-not-exist
 then false; else true; fi
 
 # Loading nonexistent file.
-if $herd load dmd /does/not/exist.scm;
+if $herd load root /does/not/exist.scm;
 then false; else true; fi
 
 # Unload one service, make sure the other it still around.
-$herd unload dmd test
+$herd unload root test
 $herd status | grep "Stopped: (test-2)"
 
-$herd reload dmd "$conf"
+$herd reload root "$conf"
 test "`$herd status`" == "$pristine_status"
 
-# Unload everything and make sure only 'dmd' is left.
-$herd unload dmd all
+# Unload everything and make sure only 'root' is left.
+$herd unload root all
 $herd status | grep "Stopped: ()"
-$herd status | grep "Started: (dmd)"
+$herd status | grep "Started: (root)"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 test -f "$log"
@@ -154,7 +154,7 @@ $herd stop test
 
 dmd_pid="`cat $pid`"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 rm -rf $confdir
diff --git a/tests/no-home.sh b/tests/no-home.sh
index 5f8d752..5af51e6 100644
--- a/tests/no-home.sh
+++ b/tests/no-home.sh
@@ -43,8 +43,8 @@ dmd_pid="$!"
 while ! test -f "$pid" ; do kill -0 "$dmd_pid" ; sleep 0.3 ; done
 
 kill -0 `cat "$pid"`
-$herd status dmd
-$herd stop dmd
+$herd status root
+$herd stop root
 
 if kill `cat "$pid"`
 then
diff --git a/tests/respawn.sh b/tests/respawn.sh
index 695d536..057c3ea 100644
--- a/tests/respawn.sh
+++ b/tests/respawn.sh
@@ -122,4 +122,4 @@ $herd status test1 | grep stopped
 ! kill -0 "$pid"
 
 cat $service2_pid
-$herd stop dmd
+$herd stop root
diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh
index 02bba3d..3452a15 100644
--- a/tests/status-sexp.sh
+++ b/tests/status-sexp.sh
@@ -62,14 +62,15 @@ test -S "$socket"
 # Code to fetch service status info.
 fetch_status="
   (let ((sock (open-connection \"$socket\")))
-    (write-command (shepherd-command 'status 'dmd) sock)
+    (write-command (shepherd-command 'status 'root) sock)
     (read sock))"
 
-dmd_service_sexp="
+root_service_sexp="
    (service (version 0)
-      (provides (dmd)) (requires ())
+      (provides (root shepherd))
+      (requires ())
       (respawn? #f)
-      (docstring \"The dmd service is used to operate on dmd itself.\")
+      (docstring \"The root service is used to operate on shepherd itself.\")
       (enabled? #t) (running #t) (last-respawns ()))"
 
 "$GUILE" -c "
@@ -80,7 +81,7 @@ dmd_service_sexp="
    (('reply _ ('result (services)) ('error #f) ('messages ()))
     (lset= equal?
             services
-          '($dmd_service_sexp
+          '($root_service_sexp
             (service (version 0)
               (provides (foo)) (requires ())
               (respawn? #t) (docstring \"Foo!\")
@@ -108,8 +109,8 @@ dmd_service_sexp="
    (pk 'wrong x)
    (exit 1)))"
 
-# Unload everything and make sure only 'dmd' is left.
-$herd unload dmd all
+# Unload everything and make sure only 'root' is left.
+$herd unload root all
 
 "$GUILE" -c "
 (use-modules (shepherd comm))
@@ -118,10 +119,10 @@ $herd unload dmd all
   (equal? $fetch_status
           '(reply
             (version 0)
-            (result (($dmd_service_sexp)))
+            (result (($root_service_sexp)))
             (error #f) (messages ()))))"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 test -f "$log"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]