aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorAndreas Enge <andreas@enge.fr>2023-04-22 09:21:22 +0200
committerAndreas Enge <andreas@enge.fr>2023-04-22 09:21:22 +0200
commitd1252b597d8b6c77746da7b7417d958f00d01dc6 (patch)
treee2cdc9b0938e5ed7ac1b095b83c5760bbedecb87 /gnu/services
parent3f7ae420d8a54d4e2ab7f349c40d8930fe9e0771 (diff)
parent040d35f088e0f1c856f3f5a9b6bf889b17bd68b3 (diff)
downloadguix-d1252b597d8b6c77746da7b7417d958f00d01dc6.tar
guix-d1252b597d8b6c77746da7b7417d958f00d01dc6.tar.gz
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/base.scm134
-rw-r--r--gnu/services/databases.scm14
-rw-r--r--gnu/services/dns.scm1
-rw-r--r--gnu/services/herd.scm12
-rw-r--r--gnu/services/rsync.scm8
5 files changed, 104 insertions, 65 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index dfc7571e55..e8eae72aa2 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -15,7 +15,7 @@
;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2021 qblade <qblade@protonmail.com>
;;; Copyright © 2021 Hui Lu <luhuins@163.com>
-;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 muradm <mail@muradm.net>
;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
@@ -1428,7 +1428,11 @@ the tty to run, among other things."
(list (shepherd-service
(documentation "Run libc's name service cache daemon (nscd).")
(provision '(nscd))
- (requirement '(user-processes))
+
+ ;; Logs are written with syslog(3), which writes to /dev/console
+ ;; when nobody's listening--ugly. Thus, wait for syslogd.
+ (requirement '(user-processes syslogd))
+
(start #~(make-forkexec-constructor
(list #$nscd "-f" #$nscd.conf "--foreground")
@@ -1497,31 +1501,36 @@ given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
Service Switch}, for an example."
(service nscd-service-type config))
-;; Snippet adapted from the GNU inetutils manual.
+;;; Snippet adapted from the GNU inetutils manual.
(define %default-syslog.conf
- (plain-file "syslog.conf" "
- # Log all error messages, authentication messages of
- # level notice or higher and anything of level err or
- # higher to the console.
- # Don't log private authentication messages!
- *.alert;auth.notice;authpriv.none -/dev/console
-
- # Log anything (except mail) of level info or higher.
- # Don't log private authentication messages!
- *.info;mail.none;authpriv.none -/var/log/messages
-
- # Log \"debug\"-level entries and nothing else.
- *.=debug -/var/log/debug
-
- # Same, in a different place.
- *.info;mail.none;authpriv.none -/dev/tty12
-
- # The authpriv file has restricted access.
- # 'fsync' the file after each line (hence the lack of a leading dash).
- authpriv.* /var/log/secure
-
- # Log all the mail messages in one place.
- mail.* -/var/log/maillog
+ (plain-file "syslog.conf" "\
+# See info '(inetutils) syslogd invocation' for the documentation
+# of the syslogd configuration syntax.
+
+# Log all error messages, authentication messages of
+# level notice or higher and anything of level err or
+# higher to the console.
+# Don't log private authentication messages!
+*.alert;auth.notice;authpriv.none -/dev/console
+
+# Log anything (except mail) of level info or higher.
+# Don't log private authentication messages!
+*.info;mail.none;authpriv.none -/var/log/messages
+
+# Log \"debug\"-level entries and nothing else.
+*.=debug -/var/log/debug
+
+# Same, in a different place.
+*.info;mail.none;authpriv.none -/dev/tty12
+
+# The authpriv file has restricted access.
+# 'fsync' the file after each line (hence the lack of a leading dash).
+# Also include unprivileged auth logs of info or higher level
+# to conveniently gather the authentication data at the same place.
+authpriv.*;auth.info /var/log/secure
+
+# Log all the mail messages in one place.
+mail.* -/var/log/maillog
"))
(define-record-type* <syslog-configuration>
@@ -1532,30 +1541,57 @@ Service Switch}, for an example."
(config-file syslog-configuration-config-file
(default %default-syslog.conf)))
-(define syslog-service-type
- (shepherd-service-type
- 'syslog
- (lambda (config)
- (define config-file
- (syslog-configuration-config-file config))
+;;; Note: a static file name is used for syslog.conf so that the reload action
+;;; work as intended.
+(define syslog.conf "/etc/syslog.conf")
- (shepherd-service
- (documentation "Run the syslog daemon (syslogd).")
- (provision '(syslogd))
- (requirement '(user-processes))
- (actions (list (shepherd-configuration-action config-file)))
- (start #~(let ((spawn (make-forkexec-constructor
- (list #$(syslog-configuration-syslogd config)
- "--rcfile" #$config-file)
- #:pid-file "/var/run/syslog.pid")))
- (lambda ()
- ;; Set the umask such that file permissions are #o640.
- (let ((mask (umask #o137))
- (pid (spawn)))
- (umask mask)
- pid))))
- (stop #~(make-kill-destructor))))
- (syslog-configuration)
+(define (syslog-etc configuration)
+ (match-record configuration <syslog-configuration>
+ (config-file)
+ (list `(,(basename syslog.conf) ,config-file))))
+
+(define (syslog-shepherd-service config)
+ (define config-file
+ (syslog-configuration-config-file config))
+
+ (shepherd-service
+ (documentation "Run the syslog daemon (syslogd).")
+ (provision '(syslogd))
+ (requirement '(user-processes))
+ (actions
+ (list (shepherd-configuration-action syslog.conf)
+ (shepherd-action
+ (name 'reload)
+ (documentation "Reload the configuration file from disk.")
+ (procedure
+ #~(lambda (pid)
+ (if pid
+ (begin
+ (kill pid SIGHUP)
+ (display #$(G_ "Service syslog has been asked to \
+reload its settings file.")))
+ (display #$(G_ "Service syslog is not running."))))))))
+ ;; Note: a static file name is used for syslog.conf so that the reload
+ ;; action work as intended.
+ (start #~(let ((spawn (make-forkexec-constructor
+ (list #$(syslog-configuration-syslogd config)
+ #$(string-append "--rcfile=" syslog.conf))
+ #:pid-file "/var/run/syslog.pid")))
+ (lambda ()
+ ;; Set the umask such that file permissions are #o640.
+ (let ((mask (umask #o137))
+ (pid (spawn)))
+ (umask mask)
+ pid))))
+ (stop #~(make-kill-destructor))))
+
+(define syslog-service-type
+ (service-type
+ (name 'syslog)
+ (default-value (syslog-configuration))
+ (extensions (list (service-extension shepherd-root-service-type
+ (compose list syslog-shepherd-service))
+ (service-extension etc-service-type syslog-etc)))
(description "Run the syslog daemon, @command{syslogd}, which is
responsible for logging system messages.")))
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index b7bd1e587e..e8e42d3b7b 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org>
-;;; Copyright © 2015, 2016, 2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015-2016, 2022-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
@@ -167,7 +167,8 @@ host all all ::1/128 md5"))
(define-record-type* <postgresql-configuration>
postgresql-configuration make-postgresql-configuration
postgresql-configuration?
- (postgresql postgresql-configuration-postgresql) ;file-like
+ (postgresql postgresql-configuration-postgresql ;file-like
+ (default postgresql-10))
(port postgresql-configuration-port
(default 5432))
(locale postgresql-configuration-locale
@@ -308,11 +309,12 @@ host all all ::1/128 md5"))
(call-with-input-file #$pid-file read))
(_ #t))))))
(list (shepherd-service
- (provision '(postgres))
+ (provision '(postgres postgresql))
(documentation "Run the PostgreSQL daemon.")
(requirement '(user-processes loopback syslogd))
(modules `((ice-9 match)
,@%default-modules))
+ (actions (list (shepherd-configuration-action config-file)))
(start (action "start"))
(stop (action "stop"))))))))
@@ -329,8 +331,7 @@ host all all ::1/128 md5"))
(service-extension
profile-service-type
(compose list postgresql-configuration-postgresql))))
- (default-value (postgresql-configuration
- (postgresql postgresql-10)))
+ (default-value (postgresql-configuration))
(description "Run the PostgreSQL database server.")))
(define-deprecated (postgresql-service #:key (postgresql postgresql)
@@ -595,6 +596,8 @@ port=" (number->string port) "
(provision '(mysql))
(requirement '(user-processes))
(documentation "Run the MySQL server.")
+ (actions (list (shepherd-configuration-action
+ (mysql-configuration-file config))))
(start (let ((mysql (mysql-configuration-mysql config))
(extra-env (mysql-configuration-extra-environment config))
(my.cnf (mysql-configuration-file config)))
@@ -752,6 +755,7 @@ port=" (number->string port) "
(provision '(redis))
(documentation "Run the Redis daemon.")
(requirement '(user-processes syslogd))
+ (actions (list (shepherd-configuration-action config-file)))
(start #~(make-forkexec-constructor
'(#$(file-append redis "/bin/redis-server")
#$config-file)
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 2ff9f90cd0..f45fc99c69 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -622,6 +622,7 @@
(documentation "Run the Knot DNS daemon.")
(provision '(knot dns))
(requirement '(networking))
+ (actions (list (shepherd-configuration-action config-file)))
(start #~(make-forkexec-constructor
(list (string-append #$knot "/sbin/knotd")
"-c" #$config-file)))
diff --git a/gnu/services/herd.scm b/gnu/services/herd.scm
index e489ce2b9a..48594015fc 100644
--- a/gnu/services/herd.scm
+++ b/gnu/services/herd.scm
@@ -282,14 +282,10 @@ returns a shepherd <service> object."
`(primitive-load ,file))
files))))
-(define (load-services/safe files)
- "This is like 'load-services', but make sure only the subset of FILES that
-can be safely reloaded is actually reloaded."
- (eval-there `(let ((services (map primitive-load ',files)))
- ;; Since version 0.5.0 of the Shepherd, registering a service
- ;; that has the same name as an already-registered service
- ;; makes it a "replacement" of that previous service.
- (apply register-services services))))
+(define load-services/safe
+ ;; Deprecated. It used to behave differently before service replacements
+ ;; were a thing.
+ load-services)
(define* (start-service name #:optional (arguments '()))
(invoke-action name 'start arguments
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index d456911563..aeb4275031 100644
--- a/gnu/services/rsync.scm
+++ b/gnu/services/rsync.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
-;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -225,13 +225,15 @@ please use 'modules' instead~%")))
(pid-file (rsync-configuration-pid-file config))
(port-number (rsync-configuration-port-number config))
(user (rsync-configuration-user config))
- (group (rsync-configuration-group config)))
+ (group (rsync-configuration-group config))
+ (config-file (rsync-config-file config)))
(list (shepherd-service
(provision '(rsync))
(documentation "Run rsync daemon.")
+ (actions (list (shepherd-configuration-action config-file)))
(start #~(make-forkexec-constructor
(list (string-append #$rsync "/bin/rsync")
- "--config" #$(rsync-config-file config)
+ "--config" #$config-file
"--daemon")
#:pid-file #$pid-file
#:user #$user