aboutsummaryrefslogtreecommitdiff
path: root/src/property/service.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-06-18 09:18:05 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-06-18 09:18:05 -0700
commitac323afe9320eb3dca745e4e61cbe94c544b3afd (patch)
tree7c049a6d07575be38a8480a4e23362acac88f1d5 /src/property/service.lisp
parentbd6cb86c97ba0f97aee1941e190bd9f19f42f440 (diff)
downloadconsfigurator-ac323afe9320eb3dca745e4e61cbe94c544b3afd.tar.gz
add SERVICE:RESTARTED, SERVICE:RELOADED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/service.lisp')
-rw-r--r--src/property/service.lisp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/property/service.lisp b/src/property/service.lisp
index f88f9fd..2171c71 100644
--- a/src/property/service.lisp
+++ b/src/property/service.lisp
@@ -48,6 +48,10 @@ not affect you."
(os:etypecase
(debianlike (%policy-rc.d))))
+(defun service (service action)
+ (unless (get-hostattrs-car :no-services)
+ (run :may-fail "service" service action)))
+
(defprop running :posix (service)
"Attempt to start service using service(1).
Assumes that if service(1) returns nonzero, it means the service was already
@@ -55,11 +59,18 @@ running. If something more robust is required, use init system-specific
properties."
(:desc #?"Attempt to start ${service} has been made")
(:apply
- (unless (get-hostattrs-car :no-services)
- (run :may-fail "service" service "start"))
+ (service service "start")
;; assume it was already running
:no-change))
+(defprop restarted :posix (service)
+ (:desc "Attempt to restart ${service}")
+ (:apply (service service "restart")))
+
+(defprop reloaded :posix (service)
+ (:desc "Attempt to reload ${service}")
+ (:apply (service service "reload")))
+
(define-function-property-combinator without-starting-services (&rest propapps)
"Apply PROPAPPS with SERVICE:NO-SERVICES temporarily in effect."
(let ((propapp (if (cdr propapps) (apply #'eseqprops propapps) (car propapps))))