Next: Methods of services, Up: Services [Contents][Index]
A service has the following slots, all of which can be initialized
with a keyword (i.e. #:provides
, used when creating the object)
of the same name, except where stated otherwise. You should not
access them directly with slot-ref
or slot-set!
usually, use the methods of the service class Methods of services instead.
provides
is a list of symbols that are provided by the service.
A symbol can only be provided by one service running at a time,
i.e. if two services provide the same symbol, only one of them can
run, starting the other one will fail. Therefore, these symbols are
mainly used to denote conflicting services. The first symbol in the
list is the canonical name for the service, thus it must be unique.
This slot has no default value and must therefore be initialized.
requires
is, like provides
, a list of symbols that
specify services. In this case, they name what this service depends
on, i.e. before the service can be started, services that provide
those symbols must be started. If a required symbol is provided by
several services, one will be started. By default, this slot
contains the empty list.
running
is a hook that can be used by each service in its own
way. The default value is #f
, which indicates that the service
is not running. When an attempt is made to start the service, it will
be set to the return value of the procedure in the start
slot.
It will also be passed as an argument to the procedure in the
stop
slot. This slot can not be initialized with a keyword.
respawn?
specifies whether the service should be respawned by
dmd. If this slot has the value #t
, then assume the
running
slot specifies a child process PID and restart the
service if that process terminates. Otherwise this slot is #f
,
which is the default. See also the last-respawns
slot.
start
contains the “constructor” for the service, which will
be called to start the service. (Therefore, it is not a constructor
in the sense that it initializes the slots of a <service>
object.) This must be a procedure that accepts any amount of
arguments, which will be the additional arguments supplied by the
user. If the starting attempt failed, it must return #f
. The
value will be stored in the running
slot. The default value is
a procedure that returns #t
and performs no further actions,
therefore it is desirable to specify a different one usually.
stop
is, similar to start
, a slot containing a
procedure. But in this case, it gets the current value of the
running
slot as first argument and the user-supplied arguments
as further arguments; it gets called to stop the service. Its return
value will again be stored in the running
slot, so that it
should return #f
if it is now possible again to start the
service at a later point. The default value is a procedure that
returns #f
and performs no further actions.
actions
specifies the additional actions that can be performed
on a service when it is running. A typical example for this is the
restart
action. The macro make-actions
Service Convenience is provided to abstract the actual data representation
format for this slot. (It actually is a hash currently.)
enabled?
cannot be initialized with a keyword, and contains
#t
by default. When the value becomes #f
at some point,
this will prevent the service from getting started. A service can be
enabled and disabled with the methods enable
and
disable
, respectively Methods of services.
last-respawns
cannot be initialized with a keyword and is only
ever used when the respawn?
slot contains #t
; it is a
circular list with (car respawn-limit)
elements, where each
element contains the time when it was restarted, initially all 0,
later a time in seconds since the Epoch. The first element is the one
that contains the oldest one, the last one the newest.
stop-delay?
being false causes the stop
slot to be
unused; instead, stopping the service will just cause the
waiting-for-termination?
slot be set to #t
.
waiting-for-termination?
cannot be initialized with a keyword
and should not be used by others, it is only used internally for
respawnable services when the stop-delay?
slot contains a true
value. waiting-for-termination?
contains #t
if the
service is still running, but the user requested that it be stopped,
in which case if the service terminates the next time, the respawn
handler will not start it again.
otherwise #f
.
Next: Methods of services, Up: Services [Contents][Index]