Module: TorqueBox::Launchd

Defined in:
rake-support/lib/torquebox/launchd.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) check_install



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'rake-support/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

+ (Object) install



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'rake-support/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

+ (Object) log_dir



27
28
29
# File 'rake-support/lib/torquebox/launchd.rb', line 27

def log_dir
  File.join( TorqueBox::DeployUtils.jboss_home, 'standalone', 'logs' )
end

+ (Object) plist_dir



39
40
41
# File 'rake-support/lib/torquebox/launchd.rb', line 39

def plist_dir
  File.join( TorqueBox::DeployUtils.torquebox_home, 'share', 'init' )
end

+ (Object) plist_file



35
36
37
# File 'rake-support/lib/torquebox/launchd.rb', line 35

def plist_file
  File.join( plist_dir, 'TorqueBoxAgent.plist' )
end

+ (Object) plist_template



31
32
33
# File 'rake-support/lib/torquebox/launchd.rb', line 31

def plist_template
  File.join( plist_dir, 'TorqueBoxAgent.plist.template' )
end