aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services/databases.scm17
-rw-r--r--gnu/tests/databases.scm10
2 files changed, 21 insertions, 6 deletions
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 3b64d0e075..de1f6b8411 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -216,6 +216,14 @@ and stores the database cluster in @var{data-directory}."
(home-directory "/var/empty")
(shell (file-append shadow "/sbin/nologin")))))
+(define memcached-activation
+ #~(begin
+ (use-modules (guix build utils))
+ (let ((user (getpwnam "memcached")))
+ (mkdir-p "/var/run/memcached")
+ (chown "/var/run/memcached"
+ (passwd:uid user) (passwd:gid user)))))
+
(define memcached-shepherd-service
(match-lambda
(($ <memcached-configuration> memcached interfaces tcp-port udp-port
@@ -233,11 +241,14 @@ and stores the database cluster in @var{data-directory}."
"-p" #$(number->string tcp-port)
"-U" #$(number->string udp-port)
"--daemon"
- "-P" "/var/run/memcached.pid"
+ ;; Memcached changes to the memcached user prior to
+ ;; writing the pid file, so write it to a directory
+ ;; that memcached owns.
+ "-P" "/var/run/memcached/pid"
"-u" "memcached"
,#$@additional-options)
#:log-file "/var/log/memcached"
- #:pid-file "/var/run/memcached.pid"))
+ #:pid-file "/var/run/memcached/pid"))
(stop #~(make-kill-destructor))))))))
(define memcached-service-type
@@ -245,6 +256,8 @@ and stores the database cluster in @var{data-directory}."
(extensions
(list (service-extension shepherd-root-service-type
memcached-shepherd-service)
+ (service-extension activation-service-type
+ (const memcached-activation))
(service-extension account-service-type
(const %memcached-accounts))))
(default-value (memcached-configuration))))
diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm
index 310210c368..9d9a753747 100644
--- a/gnu/tests/databases.scm
+++ b/gnu/tests/databases.scm
@@ -63,13 +63,15 @@
(test-begin "memcached")
;; Wait for memcached to be up and running.
- (test-eq "service running"
- 'running!
+ (test-assert "service running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
- (start-service 'memcached)
- 'running!)
+ (match (start-service 'memcached)
+ (#f #f)
+ (('service response-parts ...)
+ (match (assq-ref response-parts 'running)
+ ((pid) (number? pid))))))
marionette))
(let* ((ai (car (getaddrinfo "localhost"