Module: TorqueBox::Launchd

Defined in:
lib/torquebox/launchd.rb

Class Method Summary collapse

Class Method Details

.check_installObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/torquebox/launchd.rb', line 42

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

.installObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/torquebox/launchd.rb', line 60

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_dirObject



26
27
28
# File 'lib/torquebox/launchd.rb', line 26

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

.plist_dirObject



38
39
40
# File 'lib/torquebox/launchd.rb', line 38

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

.plist_fileObject



34
35
36
# File 'lib/torquebox/launchd.rb', line 34

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

.plist_templateObject



30
31
32
# File 'lib/torquebox/launchd.rb', line 30

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