Commit Graph

820 Commits

Author SHA1 Message Date
Attila Lendvai 3fde186103
shepherd: Add --log-level command line argument. 2024-02-04 23:12:03 +01:00
Attila Lendvai 09d2648f17
support: Add public log-level accessors. 2024-02-04 23:12:03 +01:00
Attila Lendvai be611f4d25
support: Add log-level constructor. 2024-02-04 23:12:03 +01:00
Attila Lendvai 9ea4bf3349
KLUDGE: don't disable deprecation warning 2024-02-04 23:12:03 +01:00
Attila Lendvai e4e188b146
housekeeping: whitespace and other idempotent cleanups 2024-02-04 23:12:03 +01:00
Attila Lendvai bd7a0e983b
service: Factor out send-to-service-controller.
* modules/shepherd/service.scm (service-running-value): New function.
(query-service-controller), (enable-service), (disable-service),
(record-service-respawn-time), (start-service), (stop-service),
(service-registry), (handle-service-termination): Use it.
2024-02-04 23:12:02 +01:00
Attila Lendvai ad15f54678
service: Rename to query-service-controller and use cut.
* modules/shepherd/service.scm (query-service-controller): New function based
on the previous not-so-well named service-control-message.  Use cut instead of
the now deleted service-control-message.
(service-control-message): Deleted.
2024-02-04 23:12:02 +01:00
Attila Lendvai f0549f15d5
More logs and asserts. 2024-02-04 23:12:02 +01:00
Attila Lendvai 48969cf2b6
service: Factor out send-to-registry.
Also add an assert that (current-registry-channel) is not #f.
2024-02-04 23:12:02 +01:00
Attila Lendvai 994895d7e6
service: Factor out send-to-process-monitor.
Also add an assert into it that (current-process-monitor) is not #f.
2024-02-04 23:12:02 +01:00
Attila Lendvai 53193bb2c8
herd: set up logging, and add a few entries 2024-02-04 23:12:02 +01:00
Attila Lendvai 6622e9fb0d
Factor out with-initialized-logging. 2024-02-04 23:12:02 +01:00
Attila Lendvai e434498f2a
Move syslog-output-port into (shepherd support).
This way it's more widely available for use in other modules.  It'll be needed
in a followup commit.
2024-02-04 23:12:02 +01:00
Attila Lendvai 3fb633d1b2
housekeeping: indentation, code readability, fewer calls.
* modules/shepherd/service.scm (start-service): Only call start-in-parallel if
there are dependencies to start.  This reduces log noise on verbose logging.
(stop-service): Use WHEN instead of AND and BEGIN.
(start-in-parallel): Reindent.
2024-02-04 23:12:02 +01:00
Attila Lendvai fb749e8b49
Replace caught-error with the new infrastructure.
* modules/shepherd/support.scm (caught-error): Deleted.
* modules/shepherd/service.scm (stop-service): Replace the use of caught-error
with log-with-backtrace and local-output.
2024-02-04 23:12:02 +01:00
Attila Lendvai 9802dc36f5
tests: cat the shepherd log at the end of all the test logs 2024-02-04 23:12:01 +01:00
Attila Lendvai 2ab30d8cef
service: Use call-with-error-handling to guard/log errors.
* modules/shepherd/service.scm (spawn-service-controller): Add fatal log when
the controller fiber errors.
(essential-task-thunk): Add a fatal log when an essential task errors.
2024-02-04 23:12:01 +01:00
Attila Lendvai 3e236ce730
service: Rename report-exception to report-action-error.
* modules/shepherd/service.scm (report-exception): Rename to
report-action-error. Also switch the service and action arguments.
(start-service), (perform-service-action): Adjust accordingly.
2024-02-04 23:12:01 +01:00
Attila Lendvai a12dae1518
shepherd: Guard the command listeners against errors.
This makes sure that Shepherd continues listening for commands if some error
happens while reading them from the socket or from stdin.

* modules/shepherd.scm (run-daemon): Wrap command reading and processing with
call-with-error-handling.
(process-textual-commands): Ditto.
2024-02-04 23:12:01 +01:00
Attila Lendvai ea9a0fba4d
shepherd: Populate the code with some more log lines. 2024-02-04 23:12:01 +01:00
Attila Lendvai 1965e9ce87
shepherd: Populate the code with some log lines. 2024-02-04 23:12:01 +01:00
Attila Lendvai 76bf3b10a7
service: report-exception logs the error and the backtrace.
* modules/shepherd/service.scm (report-exception): Add a call to
log-with-backtrace.
2024-02-04 23:12:01 +01:00
Attila Lendvai acca540894
README: Add hint to configure log line coloring in Emacs. 2024-02-04 23:12:01 +01:00
Attila Lendvai 3adb7b846a
support: Add logging operators. 2024-02-04 23:12:01 +01:00
Attila Lendvai 4a27252273
shepherd: add call-with-error-handling 2024-02-04 23:12:01 +01:00
Attila Lendvai 8c02165fb1
shepherd: Increase the time range for the default respawn limit.
There are some services that take a few seconds to start up before they
end up failing. Let's cover those use-cases.

* modules/shepherd/service.scm (default-respawn-limit): Increase the time
range to 30 seconds.
2024-02-04 23:12:00 +01:00
Attila Lendvai 13859bf7ae
shepherd: Do not respawn disabled services.
* modules/shepherd/service.scm (respawn-service): Ignore disabled services.
Also reorder the disabling of the service to happen before we print that it
has been disabled.
2024-02-04 23:12:00 +01:00
Attila Lendvai df24718c10
service: respawn-limit: make #f mean no limit.
* modules/shepherd/service.scm (respawn-service): Ignore respawn-limit when its
value is #f.
2024-02-04 23:12:00 +01:00
Attila Lendvai 8c562936f9
service: Add custom printer for <service> records.
* modules/shepherd/service.scm (write): New method.
2024-02-04 23:12:00 +01:00
Attila Lendvai f432c9ba70
shepherd: Add tests/startup-error.sh
This test is not failing as of this commit, but it's better to have an
explicit test for error handling.
2024-02-04 23:12:00 +01:00
Attila Lendvai 622d67a839
README: Add an example usage in an operating-system config. 2024-02-04 23:12:00 +01:00
Attila Lendvai b7b31c2889
.gitignore: adjust for tests/, m4/, po/ 2024-02-04 23:12:00 +01:00
Attila Lendvai b28853e9ae
KLUDGE Added my key to .guix-authorizations, and set to attila-keyring. 2024-01-19 00:16:08 +01:00
Ludovic Courtès 9ffefd780d
build: Bump to version 0.10.3.
* configure.ac: Bump to version 0.10.3.
2024-01-07 11:51:38 +01:00
Ludovic Courtès c587772fe5
Update NEWS. 2024-01-07 11:48:32 +01:00
Ludovic Courtès 8773c128cd
nls: Update de, ro, sr, sv, and uk translations. 2024-01-07 11:46:22 +01:00
Ludovic Courtès f20758f86b
tests: Make ‘forking-service.sh’ more tolerant of delays.
This is helpful for systems without ‘signalfd’, which may react more
slowly, and when testing on slower machines.

* tests/forking-service.sh: Define ‘within_seconds’ and use it when
checking service death and respawn.  Set #:respawn-delay for ‘test2’.
2024-01-06 23:33:12 +01:00
Ludovic Courtès 2bde245dea
guix: Build Shepherd with Fibers using the libevent backend.
* .guix/modules/shepherd-package.scm (guile-fibers-on-libevent)
(shepherd/libevent): New variables.
* .guix/manifest.scm (native-builds): Add SHEPHERD/LIBEVENT.
2024-01-06 15:12:46 +01:00
Ludovic Courtès 3e7194bae9
guix: Enable GNU/Hurd compilation and cross-compilation.
* .guix/manifest.scm (native-builds): Add “i586-gnu”.
(cross-builds): Add “i586-pc-gnu”.
2024-01-06 14:52:59 +01:00
Ludovic Courtès 79b8bd8af4
support: ‘primitive-load*’ opens files with O_CLOEXEC.
* modules/shepherd/support.scm (call-with-port) [!guile-3]: New procedure.
(primitive-load*): Use it, and open FILE with O_CLOEXEC.
2024-01-05 00:52:47 +01:00
Ludovic Courtès f8ff40b0a0
service: ‘start-in-the-background’ shows each failure only once.
Previously, failing services would be listed as many times as they had
been unsuccessfully started.

* modules/shepherd/service.scm (start-in-the-background): Add call to
‘delete-duplicates’ when displaying FAILURES.
2024-01-05 00:29:22 +01:00
Ludovic Courtès 8dbe55b339
shepherd: Really replace the core ‘sleep’ binding.
Commit fc75133d39 would only replace the
local ‘sleep’ binding.

* modules/shepherd.scm (main): Really replace (@ (guile) sleep).
2024-01-05 00:28:20 +01:00
Ludovic Courtès a4abb9d7b6
build: Bump to version 0.10.3rc1.
* configure.ac: Bump to version 0.10.3rc1.
2024-01-02 23:37:36 +01:00
AwesomeAdam54321 ad07f8d7e7
doc: Add init system config for another distro.
* doc/examples/awesomeadam.scm: New file.
* Makefile.am (EXTRA_DIST): Add it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-02 23:37:36 +01:00
Ludovic Courtès a6b188024b
Update NEWS. 2024-01-02 23:08:18 +01:00
Ludovic Courtès 520094a67f
support: Update copyright year in ‘--version’ output.
* modules/shepherd/support.scm (display-version): Update to 2024.
2024-01-01 23:37:49 +01:00
Ludovic Courtès 2563bc01be
service: inetd: Clear O_NONBLOCK on the connection socket.
Fixes a portability issue for GNU/Hurd.

* modules/shepherd/service.scm (make-inetd-constructor): Add ‘fcntl’
calls before calling ‘spawn-child-service’.
2024-01-01 23:33:07 +01:00
Ludovic Courtès 15eb04e82b
service: No SO_REUSEADDR for AF_UNIX sockets.
This fixes execution on GNU/Hurd, where ‘setsockopt’ would return
ENOPROTOOPT.

* modules/shepherd/service.scm (endpoint->listening-socket): Do not set
SO_REUSEADDR on AF_UNIX sockets.
2024-01-01 17:56:14 +01:00
Ludovic Courtès 839823eb61
service: Improve handling of the no-PR_SET_CHILD_SUBREAPER case.
This is used on GNU/Hurd when not running as PID 1.

* modules/shepherd/service.scm (check-for-dead-services): Send a message
to the process monitor instead of calling ‘respawn-service’.
2024-01-01 17:55:00 +01:00
Ludovic Courtès d15e833544
tests: Deal with ‘setrlimit’ behavior on GNU/Hurd.
* tests/forking-service.sh, tests/system-star.sh: Conditionalize tests
that rely on ‘setrlimit’.
2023-12-31 20:51:18 +01:00