Friday, November 3, 2017

SMF service - methods

Related to an SMF service restarter are the methods it supports for influencing the (running) state of a service instance which have been assigned to it. A method implementation typically invokes a binary (daemon), a script (for more complex start-ups) or yet a special SMF method keyword (:true or :kill).

For the master restarter, the default restarter, two mandatory methods must be implemented (or inherited from the service) by an instance:
 
  • start
    May invoke a binary or a script to launch the instance.
    Except for child model, the instance must fully come on-line.
    Any non-zero return value or exceed timeout is an error. 
     
  • stop
    If (re)invoked to an already stopp(ed/ing) instance: not an error.
    If the instance doesn't (imperatively) stop: must flag en error.
     
An optional refresh method is also supported by svc.startd for:
Reloading configuration from the SMF repository or standard files.
By all means, the instance must not be otherwise disturbed.
For daemons, traditionally implemented via a SIGHUP.
If not supported by the instance, it must be omitted.

NOTE
It's not clear in the public documentation if omitting the refresh method, when it's the case, would have the same net effect of implementing it as :true.

Example:

...

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

  ...

  <!-- service shared stop method -->
  <exec_method type="method" name="stop"
   exec="..." 
   timeout_seconds="..." />

 
<instance enabled="..." name="..." >

    <!-- instance specific start method -->
    <exec_method type="method" name="start"
     exec="..." 
     timeout_seconds="..." />

    ...

 
</instance >

  <instance enabled="..." name="..." >

    <!-- instance specific start method --> 
    <exec_method type="method" name="start"
     exec="..." 
     timeout_seconds="..." />

    ...

 
</instance >

  ...

</service >

... 


NOTE
In the example above,  the timeout_seconds aren't shown, but the good practice recommends scaling as needed, but according to an instance typical start-up time, similarly to following sample scheme:

Up to   Time-out
-----   --------
   1s :      60s
  30s :     300s

From which perhaps, I could infer that:

Up to   Time-out
-----   --------
 300s :     900s
 600s :    1200s