Friday, November 3, 2017

SMF service - restarter

SMF properties are also important to communicate to the SMF framework how a SMF service is to be handled, that is, how the framework should attempt to maintain availability of a particular service in terms of how and which restart methods and capabilities should be attempted by the designated restarter (by default, svc.startd, a.k.a. system/svc/restarter or the master restarter). This all has to do with the bright words: service model.

A service model is related to the supported service restart capabilities of the service restarter associated to a service. At the SMF development level, the interface to the default service restarter is achieved by certain overrides to a special property group known as startd of type framework. This way, it's possible to communicate to the framework, which service model the service restarter should apply to the given service.

Documentation about the service models supported by svc.startd seems old and scarce. In essence, it's supported by the duration property of the startd special property group.

Currently, 3 service models have been documented:

  • Contract (default)
    The usual daemons that should run forever.
    Death of all processes is an error and will trigger a restart.
     
  • Wait
    A service that runs for the lifetime of the child process.
    When that child process exit the service is restarted.
     
  • Transient
    Usually a first-run / one-time service.
    Example: a configuration and/or cleanup service.
    The SMF framework won't bother maintaining availability.

Example:

...

<service type="service" version="..."
 name="..." >

  ...

  <!-- must come before the stability tag, if present -->
  <property_group type="framework" name="startd" >

    <propval type="astring"
    
name="duration" value="transient" />

  </property_group >

  ...

</service >

... 


NOTE
Another possibly useful property of svc.startd is ignore_error, specially when the given instance has sub-processes from which eventual coredumps aren't to be considered faults meriting SMF attention or to which external kill signals are not to be considered as errors by SMF.

Example:

<propval type="astring"
 name="ignore_error"
value="core,signal" /
>

NOTE
Beyond svc.startd (the default restarter), Solaris 11.3 documentation also refers to a svc.periodicd restarter, which seems to behave similarly to crontab.