Module: TorqueBox::Upstart

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

Class Method Summary (collapse)

Class Method Details

+ (Object) check_install



55
56
57
58
59
# File 'rake-support/lib/torquebox/upstart.rb', line 55

def check_install
  TorqueBox::DeployUtils.check_opt_torquebox
  raise "#{init_torquebox} not installed in #{init_dir}" unless ( File.exist?( init_torquebox ) )
  puts "TorqueBox init scripts OK: #{init_torquebox}"
end

+ (Object) copy_init_script(opts = {})



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'rake-support/lib/torquebox/upstart.rb', line 40

def copy_init_script(opts={})
  if File.writable?( init_dir )
    if ( server_opts = TorqueBox::DeployUtils.find_option(opts, 'server_opts') )
      to_init_file = File.join( init_dir, File.basename(init_script) )
      File.open( to_init_file, 'w' ) do |f|
        f.write( process_init_template(server_opts) )
      end
    else
      FileUtils.cp( init_script, init_dir )
    end
  else
    puts "Cannot write upstart configuration to #{init_dir}. You'll need to copy #{init_script} to #{init_dir} yourself."
  end
end

+ (Object) init_dir



28
29
30
# File 'rake-support/lib/torquebox/upstart.rb', line 28

def init_dir
  File.join( TorqueBox::DeployUtils.sys_root, 'etc', 'init' )
end

+ (Object) init_script



32
33
34
# File 'rake-support/lib/torquebox/upstart.rb', line 32

def init_script
  File.join( TorqueBox::DeployUtils.torquebox_home, 'share', 'init', 'torquebox.conf' )
end

+ (Object) init_torquebox



36
37
38
# File 'rake-support/lib/torquebox/upstart.rb', line 36

def init_torquebox
  File.join( init_dir, 'torquebox.conf' )
end

+ (Object) process_init_template(server_opts)



62
63
64
65
# File 'rake-support/lib/torquebox/upstart.rb', line 62

def process_init_template(server_opts)
  template = ERB.new File.new( "#{init_script}.erb" ).read
  template.result(binding)
end