Module Lwt_launchd
Allow an application to be managed by launchd.
val activate_socket : string -> (Lwt_unix.file_descr list, Launchd.error) Stdlib.result Lwt.t
activate_socket name
: retrieve the file descriptors for the sockets associated with the givenname
in the .plist file. This should be called once per invocation; subsequent calls will fail with`Ealready
.For example, in the following .plist,
name
should be"Listener"
:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.recoil.dave.anotherd</string> <key>ProgramArguments</key> <array> <string>/path/to/binary</string> </array> <key>Sockets</key> <dict> <key>Listener</key> <dict> <key>SockServiceName</key> <string>8081</string> <key>SockType</key> <string>stream</string> <key>SockFamily</key> <string>IPv4</string> </dict> </dict> </dict> </plist>
Please note that launchd may bind multiple sockets (e.g. one for IPv4 and another for IPv6) and so the application must handle all the sockets returned by the call.
Please note that this call is blocking.
This call fails with:
`Enoent name
ifname
could not be found in the .plist.`Esrch
if this process is not being managed by launchd (for example if it is running from a terminal).`Ealready
if the socket has already been activated.