>From d91b7be586cb2edda6fd67bb6ef44a71bd669149 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Fri, 22 Jan 2016 22:19:46 +0300 Subject: [PATCH 3/4] Rename 'dmd' service to 'shepherd'. * modules/shepherd/service.scm (dmd-service): Rename to... (shepherd-service): ... this. 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. --- modules/halt.scm | 2 +- modules/herd.scm | 11 +++++---- modules/reboot.scm | 2 +- modules/shepherd.scm | 10 ++++---- modules/shepherd/service.scm | 46 ++++++++++++++++++------------------ modules/shepherd/support.scm | 4 ++-- shepherd.texi | 55 ++++++++++++++++++++++---------------------- tests/basic.sh | 24 +++++++++---------- tests/no-home.sh | 4 ++-- tests/respawn.sh | 2 +- tests/status-sexp.sh | 18 +++++++-------- 11 files changed, 89 insertions(+), 89 deletions(-) diff --git a/modules/halt.scm b/modules/halt.scm index 0f4a814..244d292 100644 --- a/modules/halt.scm +++ b/modules/halt.scm @@ -50,7 +50,7 @@ (with-system-error-handling (let ((sock (open-connection socket-file))) ;; Send the command without further ado. - (write-command (shepherd-command 'power-off 'dmd) sock) + (write-command (shepherd-command 'power-off 'shepherd) sock) ;; Receive output. (setvbuf sock _IOLBF) diff --git a/modules/herd.scm b/modules/herd.scm index 3b330cb..9f168e6 100644 --- a/modules/herd.scm +++ b/modules/herd.scm @@ -100,7 +100,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? service 'shepherd) + (eq? action 'detailed-status)) 'status action))) ;; Send the command. @@ -122,9 +123,9 @@ the daemon via SOCKET-FILE." ;; Then interpret the result (match (list action service) - (('status 'dmd) + (('status 'shepherd) (display-status-summary (first result))) - (('detailed-status 'dmd) + (('detailed-status 'shepherd) (display-detailed-status (first result))) (('status _) ;; We get a list of statuses, in case several services have the @@ -167,7 +168,7 @@ on service '~a':~%") ((? 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) (eq? service 'shepherd)) (format (current-error-port) (l10n "premature end-of-file while talking to shepherd~%")) (exit 1)))) @@ -198,7 +199,7 @@ on service '~a':~%") (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) 'shepherd '())) ((action service args ...) (run-command socket-file (string->symbol action) diff --git a/modules/reboot.scm b/modules/reboot.scm index df21c7f..7e75768 100644 --- a/modules/reboot.scm +++ b/modules/reboot.scm @@ -50,7 +50,7 @@ (with-system-error-handling (let ((sock (open-connection socket-file))) ;; Send the command without further ado. - (write-command (shepherd-command 'stop 'dmd) sock) + (write-command (shepherd-command 'stop 'shepherd) sock) ;; Receive output. (setvbuf sock _IOLBF) diff --git a/modules/shepherd.scm b/modules/shepherd.scm index 1a14f09..352d59d 100644 --- a/modules/shepherd.scm +++ b/modules/shepherd.scm @@ -143,8 +143,8 @@ ;; Send output to log and clients. (set-current-output-port shepherd-output-port) - ;; Start the dmd service. - (start dmd-service) + ;; Start the shepherd service. + (start shepherd-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.) @@ -178,7 +178,7 @@ ;; ctrlaltdel(8). (sigaction SIGINT (lambda _ - (stop dmd-service))) + (stop shepherd-service))) (if (not socket-file) ;; Get commands from the standard input port. @@ -260,7 +260,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. + ;; SHEPHERD-SERVICE. So, if we're running as 'root', just reboot. (if (zero? (getuid)) (begin (local-output "Rebooting...") @@ -276,7 +276,7 @@ would write them on the 'herd' command line." (if (eof-object? line) ;; Exit on `C-d'. - (stop dmd-service) + (stop shepherd-service) (begin (match (string-tokenize line) diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index 46dc4c7..8726919 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -69,7 +69,7 @@ make-system-destructor make-init.d-service - dmd-service + shepherd-service make-actions &service-error @@ -343,8 +343,8 @@ wire." (slot-ref obj 'running) args)) (lambda (key . args) - ;; Special case: `dmd' may quit. - (and (eq? dmd-service obj) + ;; Special case: `shepherd' may quit. + (and (eq? shepherd-service obj) (eq? key 'quit) (apply quit args)) (caught-error key args))) @@ -404,8 +404,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: `shepherd' may quit. + (and (eq? shepherd-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 shepherd help'."))))) ;; Return a list of canonical names of the services that conflict with ;; OBJ. @@ -940,7 +940,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 for shepherd. 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 @@ -971,7 +971,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 (eq? key 'shepherd)) (cons key service))) (_ #f))) ; all other cases: #f. services))) @@ -1022,7 +1022,7 @@ requested to be removed." -;; The `dmd' service. +;; The `shepherd' service. (define (shutdown-services) "Shut down all the currently running services; update the persistent state @@ -1042,10 +1042,10 @@ file when persistence is enabled." (lambda (p) (format p "~{~a ~}~%" running-services)))))) -(define dmd-service +(define shepherd-service (make - #:docstring "The dmd service is used to operate on dmd itself." - #:provides '(dmd) + #:docstring "The shepherd service is used to operate on shepherd itself." + #:provides '(shepherd) #:requires '() #:respawn #f #:start (lambda args @@ -1053,9 +1053,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! shepherd-service 'running #f) (shutdown-services) (quit)) ;; All actions here need to take care that they do not invoke any @@ -1075,7 +1075,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 shepherd-service) (lambda (key) (local-output "Halting...") (halt))))) @@ -1084,25 +1084,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 shepherd-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 shepherd 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 @@ -1110,7 +1110,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." @@ -1136,7 +1136,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))) @@ -1144,8 +1144,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 shepherd." (lambda (running) (local-output "You must be kidding.")))))) -(register-services dmd-service) +(register-services shepherd-service) diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm index 2439085..f1878a6 100644 --- a/modules/shepherd/support.scm +++ b/modules/shepherd/support.scm @@ -223,8 +223,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..3245619 100644 --- a/shepherd.texi +++ b/shepherd.texi @@ -278,19 +278,18 @@ 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{shepherd}, 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: @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 +321,7 @@ 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{shepherd} service is used to control @command{shepherd} itself. @end itemize @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -446,11 +445,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{shepherd} 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 shepherd and unknown services}, for +more information on the @code{shepherd} 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 +491,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 +517,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 +554,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 shepherd and unknown services:: Special services in the Shepherd. @end menu @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -749,7 +748,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 @code{shepherd}. @end deffn @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -917,15 +916,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 shepherd and unknown services address@hidden The @code{shepherd} and @code{unknown} services address@hidden dmd service address@hidden shepherd 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{shepherd} 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). @table @code @item status diff --git a/tests/basic.sh b/tests/basic.sh index 386b2b0..4b7ac64 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 shepherd` # Prep for 'reload' test. +echo $pristine_status | grep -E '(Start.*shepherd|Stop.*test)' $herd start test test -f "$stamp" @@ -97,30 +97,30 @@ 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 shepherd then false; else true; fi # Wrong number of arguments for an action. -if $herd status dmd foo bar baz; +if $herd status shepherd foo bar baz; then false; else true; fi # Loading nonexistent file. -if $herd load dmd /does/not/exist.scm; +if $herd load shepherd /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 shepherd test $herd status | grep "Stopped: (test-2)" -$herd reload dmd "$conf" +$herd reload shepherd "$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 'shepherd' is left. +$herd unload shepherd all $herd status | grep "Stopped: ()" -$herd status | grep "Started: (dmd)" +$herd status | grep "Started: (shepherd)" -$herd stop dmd +$herd stop shepherd ! kill -0 $dmd_pid test -f "$log" @@ -149,7 +149,7 @@ $herd stop test dmd_pid="`cat $pid`" -$herd stop dmd +$herd stop shepherd ! kill -0 $dmd_pid rm -rf $confdir diff --git a/tests/no-home.sh b/tests/no-home.sh index 132753b..f326833 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 shepherd +$herd stop shepherd if kill `cat "$pid"` then diff --git a/tests/respawn.sh b/tests/respawn.sh index 629e684..eca5307 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 shepherd diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh index b47ce9a..c2c1c7a 100644 --- a/tests/status-sexp.sh +++ b/tests/status-sexp.sh @@ -62,14 +62,14 @@ 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 'shepherd) sock) (read sock))" -dmd_service_sexp=" +shepherd_service_sexp=" (service (version 0) - (provides (dmd)) (requires ()) + (provides (shepherd)) (requires ()) (respawn? #f) - (docstring \"The dmd service is used to operate on dmd itself.\") + (docstring \"The shepherd service is used to operate on shepherd itself.\") (enabled? #t) (running #t) (last-respawns ()))" "$GUILE" -c " @@ -80,7 +80,7 @@ dmd_service_sexp=" (('reply _ ('result (services)) ('error #f) ('messages ())) (lset= equal? services - '($dmd_service_sexp + '($shepherd_service_sexp (service (version 0) (provides (foo)) (requires ()) (respawn? #t) (docstring \"Foo!\") @@ -108,8 +108,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 'shepherd' is left. +$herd unload shepherd all "$GUILE" -c " (use-modules (shepherd comm)) @@ -118,10 +118,10 @@ $herd unload dmd all (equal? $fetch_status '(reply (version 0) - (result (($dmd_service_sexp))) + (result (($shepherd_service_sexp))) (error #f) (messages ()))))" -$herd stop dmd +$herd stop shepherd ! kill -0 $dmd_pid test -f "$log" -- 2.6.3