1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-22 09:05:54 +02:00

services: Add memcached.

* gnu/services/databases.scm (memcached-service-type, %memcached-accounts):
  New variables.
  (<memcached-configuration>): New record type.
  (memcached-service-type): New procedures.
* gnu/tests/databases.scm: New file.
* doc/guix.texi (Database Services): Document the new memcached service.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add entry for tests/databases.scm.
This commit is contained in:
Christopher Baines
2017-07-27 17:13:49 +01:00
parent 686144e986
commit 119fdd0d0e
4 changed files with 227 additions and 0 deletions
+73
View File
@@ -25,6 +25,7 @@
#:use-module (gnu system shadow)
#:use-module (gnu packages admin)
#:use-module (gnu packages databases)
#:use-module (guix modules)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (ice-9 match)
@@ -33,6 +34,16 @@
postgresql-service
postgresql-service-type
memcached-service-type
<memcached-configuration>
memcached-configuration
memcached-configuration?
memcached-configuration-memecached
memcached-configuration-interfaces
memcached-configuration-tcp-port
memcached-configuration-udp-port
memcached-configuration-additional-options
mysql-service
mysql-service-type
mysql-configuration
@@ -176,6 +187,68 @@ and stores the database cluster in @var{data-directory}."
(config-file config-file)
(data-directory data-directory))))
;;;
;;; Memcached
;;;
(define-record-type* <memcached-configuration>
memcached-configuration make-memcached-configuration
memcached-configuration?
(memcached memcached-configuration-memcached ;<package>
(default memcached))
(interfaces memcached-configuration-interfaces
(default '("0.0.0.0")))
(tcp-port memcached-configuration-tcp-port
(default 11211))
(udp-port memcached-configuration-udp-port
(default 11211))
(additional-options memcached-configuration-additional-options
(default '())))
(define %memcached-accounts
(list (user-group (name "memcached") (system? #t))
(user-account
(name "memcached")
(group "memcached")
(system? #t)
(comment "Memcached server user")
(home-directory "/var/empty")
(shell (file-append shadow "/sbin/nologin")))))
(define memcached-shepherd-service
(match-lambda
(($ <memcached-configuration> memcached interfaces tcp-port udp-port
additional-options)
(with-imported-modules (source-module-closure
'((gnu build shepherd)))
(list (shepherd-service
(provision '(memcached))
(documentation "Run the Memcached daemon.")
(requirement '(user-processes loopback))
(modules '((gnu build shepherd)))
(start #~(make-forkexec-constructor
`(#$(file-append memcached "/bin/memcached")
"-l" #$(string-join interfaces ",")
"-p" #$(number->string tcp-port)
"-U" #$(number->string udp-port)
"--daemon"
"-P" "/var/run/memcached.pid"
"-u" "memcached"
,#$@additional-options)
#:log-file "/var/log/memcached"
#:pid-file "/var/run/memcached.pid"))
(stop #~(make-kill-destructor))))))))
(define memcached-service-type
(service-type (name 'memcached)
(extensions
(list (service-extension shepherd-root-service-type
memcached-shepherd-service)
(service-extension account-service-type
(const %memcached-accounts))))
(default-value (memcached-configuration))))
;;;
;;; MySQL.