module Capistrano::ResqueMonit

Constants

VERSION

Public Class Methods

file_name(name) click to toggle source
# File lib/capistrano/resque_monit.rb, line 10
def self.file_name(name)
  "resque_worker_#{fetch(:resque_application)}_#{name}"
end
find_gem_home(host) click to toggle source
# File lib/capistrano/resque_monit.rb, line 32
def self.find_gem_home(host)
  gem_home = nil
  SSHKit::Coordinator.new(host).each do
    within current_path do
      gem_home = capture(:echo, '$GEM_HOME')
    end
  end
  gem_home
end
put_as_root(content, destination, host, options = {}) click to toggle source
# File lib/capistrano/resque_monit.rb, line 22
def self.put_as_root(content, destination, host, options = {})
  SSHKit::Coordinator.new(host).each do
    basename ||= File.basename(destination)
    tmp_path = "#{current_path}/tmp/#{basename}"
    upload! StringIO.new(content), tmp_path, options
    execute :sudo, "mv #{tmp_path} #{destination}"
    execute :sudo, "chown root:root #{destination}"
  end
end
root() click to toggle source
# File lib/capistrano/resque_monit.rb, line 6
def self.root
  @root ||= Gem::Specification.find_by_name('capistrano-resque_monit').gem_dir
end
template(filename, values = {}) click to toggle source
# File lib/capistrano/resque_monit.rb, line 14
def self.template(filename, values = {})
  template = File.open(File.join(Capistrano::ResqueMonit.root, 'templates', filename)).read
  unless values.empty?
    template.gsub!(/#\{([^}]+)\}/) { values[$1.to_sym] }
  end
  template
end