Class: PleaseRun::Platform::Launchd

Inherits:
Base
  • Object
show all
Defined in:
lib/pleaserun/platform/launchd.rb

Overview

The platform implementation for Appleā€™s launchd.

OS X users, this is for you!

Instance Method Summary collapse

Methods inherited from Base

#all_environment_variables, #default_file, #initialize, #log_path, #log_path_stderr, #log_path_stdout, #parsed_environment_variables, #platform, #render, #render_template, #safe_filename, #sysconfig_file, #template_path

Methods included from MustacheMethods

#escaped, #escaped_args, #quoted, #shell_args, #shell_continuation, #shell_quote

Methods included from Configurable

#configurable_setup, included, #validate

Constructor Details

This class inherits a constructor from PleaseRun::Platform::Base

Instance Method Details

#daemons_pathObject

Returns the file path to write this launchd config



9
10
11
12
13
# File 'lib/pleaserun/platform/launchd.rb', line 9

def daemons_path
  # Quoting launchctl(1):      
  #    "/Library/LaunchDaemons         System wide daemons provided by the administrator."
  return safe_filename("/Library/LaunchDaemons/{{ name }}.plist")
end

#filesObject

def daemons_path



15
16
17
18
19
# File 'lib/pleaserun/platform/launchd.rb', line 15

def files
  return Enumerator::Generator.new do |out|
    out.yield(daemons_path, render_template("program.plist"))
  end
end

#install_actionsObject

def files



21
22
23
# File 'lib/pleaserun/platform/launchd.rb', line 21

def install_actions
  return ["launchctl load #{daemons_path}"]
end

#xml_argsObject

def install_actions



25
26
27
28
# File 'lib/pleaserun/platform/launchd.rb', line 25

def xml_args
  return if args.nil?
  return args.collect { |a| "<string>#{a}</string>" }.join("\n        ")
end