Suivant: , Précédent: , Monter: Services du dossier personnel   [Table des matières][Index]


13.3.5 Gérer les démons personnels

Le module (gnu home services shepherd) prend en charge la définition de services Shepherd par utilisateur (voir Introduction dans le manuel de GNU Shepherd). Vous pouvez étendre home-shepherd-service-type avec de nouveaux services ; Guix Home se chargera ensuite de démarrer le démon shepherd pour vous à la connexion, ce qui démarrera ensuite les services que vous avez demandés.

Variable :home-shepherd-service-type

Le type de service pour le shepherd en espace utilisateur, qui vous permet de gérer les processus longs ou les tâches uniques. Le shepherd personnel n’est pas un processus d’init (PID 1), mais presque toutes les information décrites dans Services Shepherd sont applicables ici aussi.

C’est le type de service que les extensions ciblent lorsqu’elles veulent créer un service shepherd (voir Types service et services, pour un exemple). Chaque extension doit passer une liste de <shepherd-service>. Sa valeur doit être un home-shepherd-configuration, décrit plus bas.

Type de données :home-shepherd-configuration

Ce type de données représente la configuration du Shepherd.

shepherd (par défaut : shepherd)

Le paquet Shepherd à utiliser.

auto-start? (par défaut : #t)

Indique s’il faut lancer le Shepherd à la première connexion.

daemonize? (default: #t)

Whether or not to run Shepherd in the background.

silent? (default: #t)

When true, the shepherd process does not write anything to standard output when started automatically.

services (par défaut : '())

Une liste de <shepherd-service> à démarrer. Vous devriez probablement utiliser le mécanisme d’extensions des services à la place (voir Services Shepherd).

The Shepherd allows you to define timers, a special type of service that performs a given task periodically. Just like you can define timers at the system level (voir Exécution de tâches planifiées), you can do so in your home environment.

The example below defines a home environment where a Shepherd timer runs the mkid command twice per day (voir mkid invocation dans ID Database Utilities). It does so by extending home-shepherd-service-type with simple-service; the Shepherd timer itself is produced by the shepherd-timer procedure (voir shepherd-timer), which is given the service name, a gexp specifying its schedule, and a gexp specifying the command to run.

(use-modules (gnu) (guix)
             (gnu home services shepherd)
             (gnu packages idutils))

(define idutils-service
  ;; Index my 'doc' directory everyday at 12:15PM and 7:15PM.
  (simple-service
   'update-idutils-database home-shepherd-service-type
   (list (shepherd-timer '(update-idutils-database)
                         #~(calendar-event #:hours '(12 19)
                                           #:minutes '(15))
                         #~(#$(file-append idutils "/bin/mkid")
                            "doc")))))

(home-environment
  ;; …
  (services (append (list idutils-service)
                    %base-home-services)))

Voir Timers dans The GNU Shepherd Manual for more information on Shepherd timers.

The Shepherd also comes with a log rotation service, which compresses and then deletes old log files produced by services and daemons that it runs. This service is made available through home-log-rotation-service-type as described below.

Variable :home-log-rotation-service-type

This is the service type for the user Shepherd log rotation service (voir Log Rotation Service dans The GNU Shepherd Manual). Its value must be a log-rotation-configuration record, exactly as for its system-wide counterpart. Voir log-rotation-configuration, for its reference.

This service is part of %base-home-services.

Variable :home-shepherd-transient-service-type
Variable :home-shepherd-timer-service-type

These are the timer and transient Shepherd services. The former lets you schedule command execution for later, while the latter can run commands in the background as a regular service.

Voir the system timer and transient services, which are their Guix System counterparts, for more info.


Suivant: Shell sécurisé, Précédent: Services personnels de gestion de l’énergie, Monter: Services du dossier personnel   [Table des matières][Index]