mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
services: file-database: Turn into a Shepherd timer.
* gnu/services/admin.scm (file-database-mcron-jobs): Rename to… (file-database-shepherd-services): … this. Return a list of Shepherd services. (file-database-service-type): Adjust accordingly. * doc/guix.texi (File Search Services): Update documentation of ‘schedule’. Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Change-Id: I5734c629b113e54057694d2ec480abd26b7815db
This commit is contained in:
parent
aed019b646
commit
667248948a
2 changed files with 21 additions and 6 deletions
|
@ -27171,8 +27171,9 @@ The GNU@tie{}Findutils package from which the @command{updatedb} command
|
|||
is taken.
|
||||
|
||||
@item @code{schedule} (default: @code{%default-file-database-update-schedule})
|
||||
String or G-exp denoting an mcron schedule for the periodic
|
||||
@command{updatedb} job (@pxref{Guile Syntax,,, mcron, GNU@tie{}mcron}).
|
||||
This is the schedule of database updates, expressed as a string in
|
||||
traditional cron syntax or as a gexp evaluating to a Shepherd calendar
|
||||
event (@pxref{Timers,,, shepherd, The GNU Shepherd Manual}).
|
||||
|
||||
@item @code{excluded-directories} (default @code{%default-file-database-excluded-directories})
|
||||
List of regular expressions of directories to ignore when building the
|
||||
|
|
|
@ -462,7 +462,7 @@ the latter should instead be indexed by @command{guix locate} (@pxref{Invoking
|
|||
guix locate}). This list is passed to the @option{--prunepaths} option of
|
||||
@command{updatedb} (@pxref{Invoking updatedb,,, find, GNU@tie{}Findutils})."))
|
||||
|
||||
(define (file-database-mcron-jobs configuration)
|
||||
(define (file-database-shepherd-services configuration)
|
||||
(match-record configuration <file-database-configuration>
|
||||
(package schedule excluded-directories)
|
||||
(let ((updatedb (program-file
|
||||
|
@ -481,13 +481,27 @@ guix locate}). This list is passed to the @option{--prunepaths} option of
|
|||
#$(string-append "--prunepaths="
|
||||
(string-join
|
||||
excluded-directories)))))))
|
||||
(list #~(job #$schedule #$updatedb)))))
|
||||
(list (shepherd-service
|
||||
(provision '(file-database-update))
|
||||
(requirement '(user-processes))
|
||||
(modules '((shepherd service timer)))
|
||||
(start #~(make-timer-constructor
|
||||
#$(if (string? schedule)
|
||||
#~(cron-string->calendar-event #$schedule)
|
||||
schedule)
|
||||
(command '(#$updatedb))
|
||||
#:wait-for-termination? #t))
|
||||
(stop #~(make-timer-destructor))
|
||||
(documentation
|
||||
"Periodically update the system-wide file database that can be
|
||||
queried by the 'locate' command.")
|
||||
(actions (list shepherd-trigger-action)))))))
|
||||
|
||||
(define file-database-service-type
|
||||
(service-type
|
||||
(name 'file-database)
|
||||
(extensions (list (service-extension mcron-service-type
|
||||
file-database-mcron-jobs)))
|
||||
(extensions (list (service-extension shepherd-root-service-type
|
||||
file-database-shepherd-services)))
|
||||
(description
|
||||
"Periodically update the file database used by the @command{locate} command,
|
||||
which lets you search for files by name. The database is created by running
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue