package ocaml-systemd

  1. Overview
  2. No Docs
OCaml module for native access to the systemd facilities

Install

Dune Dependency

Authors

Maintainers

Sources

1.3.tar.gz
sha256=717acee7f71bc04ff3bb53c0af1231bd5c8112d4f2c1830562d5087cf1d4b152
sha512=9e69281cee9e26ee96bf33dc7624c6866021b2f227214c0e1376c101c77b245ab52c1a044c0b7be87d7a20beea81bb69fb33df450c7311b8fec3a608e650d7c2

doc/src/systemd/daemon.ml.html

Source file daemon.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module State = struct
    type t =
      | Ready 			(* Service startup is finished *)
      | Reloading		(* Service is reloading its configuration. Has to send Ready when finished reloading *)
      | Stopping		(* Service is beginning to shutdown *)
      | Status of string	(* Passes a single UTF-8 status string *)
      | Error of Unix.error     (* Service failed with Unix Erro *)
      | Bus_error of string	(* Service failed with D-Bus error-style error code *)
      | Main_pid of int 	(* The main process ID *)
      | Watchdog		(* Update the watchdog timestamp *)
  end				(* FDSTORE not implemented yet *)

external caml_code_of_unix_error : Unix.error -> int = "caml_daemon_code_of_unix_error"
external caml_notify : bool -> string -> bool = "caml_daemon_notify"

let notify ?(unset_environment = false) state =
  let open State in
  let s = match state with
    | Ready -> "READY=1"
    | Reloading -> "RELOADING=1"
    | Stopping -> "STOPPING=1"
    | Status s -> "STATUS=" ^ s
    | Error u -> "ERRNO=" ^ (string_of_int (caml_code_of_unix_error u))
    | Bus_error s -> "BUSERROR=" ^ s
    | Main_pid i -> "MAINPID=" ^ (string_of_int i)
    | Watchdog -> "WATCHDOG=1"
  in caml_notify unset_environment s

external caml_listen_fds : bool -> Unix.file_descr list = "caml_daemon_listen_fds"

let listen_fds ?(unset_environment = true) () = caml_listen_fds unset_environment;

external booted : unit -> bool = "caml_daemon_booted"

OCaml

Innovation. Community. Security.