module TorqueBox::Launchd

Public Class Methods

check_install() click to toggle source
# File lib/torquebox/launchd.rb, line 43
def check_install
  raise "#{plist_file} not installed in #{plist_dir}" unless ( File.exist?( plist_file ) )
  puts "TorqueBox plist scripts OK: #{plist_file}."
  
  launchctl_found = false; IO.popen( 'launchctl list | grep torquebox' ) do |output|
    output.each do |line|
      if line =~ /torquebox/
        puts "TorqueBox launchd script OK: #{line}"
        launchctl_found = true
        break
      end
    end
  end
  
  raise "TorqueBox launchd script not found in launchctl." unless launchctl_found
  
end
install() click to toggle source
# File lib/torquebox/launchd.rb, line 61
def install
  unless File.writable?( plist_dir )
    raise "Cannot write launchd configuration to #{plist_dir}. You'll need to copy #{plist_file} to #{plist_dir} yourself."
  end
  
  File.delete( plist_file ) if File.exists? plist_file 
  lines = File.open( plist_template, 'r' ) { |f| f.readlines }  
  File.open( plist_file, 'w' ) do |file|
    lines.each do |line|
      if line =~ /\$\{TORQUEBOX_HOME\}/
        file.puts( line.sub( /\$\{TORQUEBOX_HOME\}/, TorqueBox::DeployUtils.torquebox_home ) )
      else
        file.puts line
      end
    end
  end
  puts "Created launchd plist #{plist_file}, loading now."
  TorqueBox::DeployUtils.run_command "launchctl load #{plist_file}"
  check_install
  FileUtils.mkdir_p log_dir, :mode => 0755 unless File.exists? log_dir
end
log_dir() click to toggle source
# File lib/torquebox/launchd.rb, line 27
def log_dir
  File.join( TorqueBox::DeployUtils.jboss_home, 'standalone', 'logs' )
end
plist_dir() click to toggle source
# File lib/torquebox/launchd.rb, line 39
def plist_dir
  File.join( TorqueBox::DeployUtils.torquebox_home, 'share', 'init' )
end
plist_file() click to toggle source
# File lib/torquebox/launchd.rb, line 35
def plist_file
  File.join( plist_dir, 'TorqueBoxAgent.plist' )
end
plist_template() click to toggle source
# File lib/torquebox/launchd.rb, line 31
def plist_template
  File.join( plist_dir, 'TorqueBoxAgent.plist.template' )
end