GNU bug report logs -
#28021
[PATCH] gnu: Fix memcached service startup.
Previous Next
Reported by: Christopher Baines <mail <at> cbaines.net>
Date: Tue, 8 Aug 2017 20:49:02 UTC
Severity: normal
Tags: patch
Done: Christopher Baines <mail <at> cbaines.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28021 in the body.
You can then email your comments to 28021 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#28021
; Package
guix-patches
.
(Tue, 08 Aug 2017 20:49:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Christopher Baines <mail <at> cbaines.net>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Tue, 08 Aug 2017 20:49:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Memcached changes to the memcached user from root before writing the PID
file. This means that it must be able to write the PID file as the memcached
user.
To make this work, create the /var/run/memcached directory when the service
starts, make it owned by memcached, and change memcached to write the PID file
to /var/run/memcached/pid.
This wasn't picked up by the system test as the "service running" part was too
permissive, and only failed on an error. Instead, test the response from
calling start-service and check that the PID is a number.
* gnu/services/databases.scm (memcached-activation): New variable.
(memcached-shepherd-service): Change PID file location.
(memcached-service-type): Extend the activation-service-type.
* gnu/tests/databases.scm (run-memcached-test)[test]: Change the "service
running" test to check the response from the shepherd.
---
gnu/services/databases.scm | 17 +++++++++++++++--
gnu/tests/databases.scm | 10 ++++++----
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 3b64d0e07..de1f6b841 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 310210c36..9d9a75374 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"
--
2.14.0
Reply sent
to
Christopher Baines <mail <at> cbaines.net>
:
You have taken responsibility.
(Tue, 15 Aug 2017 21:27:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Christopher Baines <mail <at> cbaines.net>
:
bug acknowledged by developer.
(Tue, 15 Aug 2017 21:27:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 28021-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, 8 Aug 2017 21:48:39 +0100
Christopher Baines <mail <at> cbaines.net> wrote:
> Memcached changes to the memcached user from root before writing the
> PID file. This means that it must be able to write the PID file as
> the memcached user.
>
> To make this work, create the /var/run/memcached directory when the
> service starts, make it owned by memcached, and change memcached to
> write the PID file to /var/run/memcached/pid.
>
> This wasn't picked up by the system test as the "service running"
> part was too permissive, and only failed on an error. Instead, test
> the response from calling start-service and check that the PID is a
> number.
>
> * gnu/services/databases.scm (memcached-activation): New variable.
> (memcached-shepherd-service): Change PID file location.
> (memcached-service-type): Extend the activation-service-type.
> * gnu/tests/databases.scm (run-memcached-test)[test]: Change the
> "service running" test to check the response from the shepherd.
This was reviewed by lfam and rekado on IRC, and I've now pushed :)
[Message part 2 (application/pgp-signature, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 13 Sep 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 275 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.