summaryrefslogtreecommitdiff
path: root/gnu/services/memcached.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2017-03-04 16:31:30 +0000
committerChristopher Baines <christopher.baines@digital.cabinet-office.gov.uk>2017-03-04 16:58:00 +0000
commita79fb3393170e9c49c2c753b903b630124770056 (patch)
tree294c9c726fa9347b67323cabff3fb6dcf31d8b1f /gnu/services/memcached.scm
parent02903e2420d7b0c051c427e2a922cd778754c635 (diff)
downloadgnu-guix-a79fb3393170e9c49c2c753b903b630124770056.tar
gnu-guix-a79fb3393170e9c49c2c753b903b630124770056.tar.gz
Add memcached package and servicerelease_4
Diffstat (limited to 'gnu/services/memcached.scm')
-rw-r--r--gnu/services/memcached.scm94
1 files changed, 94 insertions, 0 deletions
diff --git a/gnu/services/memcached.scm b/gnu/services/memcached.scm
new file mode 100644
index 0000000000..9e4b536a96
--- /dev/null
+++ b/gnu/services/memcached.scm
@@ -0,0 +1,94 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services memcached)
+ #:use-module (gnu packages admin)
+ #:use-module (gnu packages memcached)
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu services)
+ #:use-module (gnu system shadow)
+ #:use-module (guix gexp)
+ #:use-module (guix records)
+ #:use-module (guix modules)
+ #:use-module (ice-9 match)
+ #:export (memcached-service-type
+
+ <memcached-configuration>
+ memcached-configuration
+ memcached-configuration?
+ memcached-configuration-memecached
+ memcached-configuration-interfaces
+ memcached-configuration-tcp-port
+ memcached-configuration-udp-port))
+
+;;;
+;;; 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 '("127.0.0.1")))
+ (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)
+ "-u" "memcached"
+ ,#$@additional-options)
+ #:log-file "/var/log/memcached"))
+ (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))))))