In Files

Namespace

Class/Module Index [+]

Quicksearch

Launch

Launch is a wrapper for the launch(3) API for daemons and agents spawned by launchd(8).

Launch agents and daemons MUST NOT:

Launch agents and daemons SHOULD NOT do the following as part of their starup initialization:

The above is from launchd.plist(5). Please read it for further details.

To shut down cleanly trap 'TERM' and perform any shutdown steps before exiting.

Constants

VERSION

The version of launch you are using

Public Instance Methods

launch_checkin() click to toggle source

Checks in with launch and retrieves the agent’s configuration. The configuration can be retrieved later through <tt>@launch_checkin<tt>.

# File lib/launch.rb, line 39
def launch_checkin
  response = launch_message Launch::Key::CHECKIN

  return if response.nil?

  @launch_checkin = response
end
launch_sockets(name, socket_class) click to toggle source

Creates ruby sockets from the sockets list in name. socket_class.for_fd is called for each socket in the named list.

name comes from the socket’s name key in the launchd plist.

Example plist Sockets dictionary:

<key>Sockets</key>
<dict>
  <key>EchoSocket</key>
  <dict>
    <key>SockServiceName</key>
    <string>12345</string>
  </dict>
</dict>

Example call:

servers = launch_sockets 'Echo', TCPServer

p servers.map { |server| server.addr }
# File lib/launch.rb, line 70
def launch_sockets name, socket_class
  require 'socket'

  sockets = @launch_checkin[Launch::JobKey::SOCKETS][name]

  raise Error, "no sockets found for #{name.inspect}" unless sockets

  sockets.map do |fd|
    socket_class.for_fd fd
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.