package dtools

  1. Overview
  2. Docs

Module Dtools.InitSource

Initialisation management module. Allow to define procedures that must be executed at start up, and procedures that are to be executed at exit to have a clean quit.

Sourcetype t
Sourceval start : t

Root start atom

Sourceval stop : t

Root stop atom

Sourceval make : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t

Define a init atom associated with the given (unit -> unit) procedure, which eventualy depends on others atoms (these atoms will be executed before the one currently defined) and triggers other atoms (these atoms will be executed after the one currently defined). after and before allow to register the currently defined atom in the depend and triggers lists of other atoms.

Sourceval at_start : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t

Same as make plus a shortcut for "after Init.start".

Sourceval at_stop : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t

Same as make plus a shortcut for "before Init.stop".

Sourceval exec : t -> unit

Launch the execution of a given init atom.

Sourceexception Root_prohibited of [ `User | `Group | `Both ]
Sourceval init : ?prohibit_root:bool -> (unit -> unit) -> unit

This fuction must be used to launch the main procedure of the program. It first execute the registered start atoms, then call the main procedure, then execute the registered stop atoms. Exceptions raised by the main procedure are catched, in order to close properly even in such cases. Exceptions are raised again after cleaning. When invoqued with ~prohibit_root:true, it checks for root access rights (euid, egid) and exit in this case.

Sourceexception StartError of exn
Sourceexception StopError of exn
Sourceval conf : Conf.ut
Sourceval conf_daemon : bool Conf.t
Sourceval conf_daemon_pidfile : bool Conf.t
Sourceval conf_daemon_pidfile_path : string Conf.t
Sourceval conf_concurrent : bool Conf.t
Sourceval conf_trace : bool Conf.t
Sourceval conf_catch_exn : bool Conf.t
Sourceval args : (string list * Arg.spec * string) list

A set of command line options to be used with the Arg module.

OCaml

Innovation. Community. Security.