Sha256: 822d9e2d52fe15776e1b6a6f8398e938a3092d3db497e8291bc8dc2ad9db678c

Contents?: true

Size: 1.42 KB

Versions: 24

Compression:

Stored size: 1.42 KB

Contents

#########
## Adds support to monitor delayed_job processes through eye
#########
def delayed_job_args
  args = []
  args << "--queues=#{fetch(:delayed_job_queues).join(',')}" unless fetch(:delayed_job_queues).nil?
  args << "--prefix=#{fetch(:delayed_job_prefix)}" unless fetch(:delayed_job_prefix).nil?
  args << fetch(:delayed_job_pools, {}).map {|k,v| "--pool=#{k}:#{v}"}.join(' ') unless fetch(:delayed_job_pools).nil?
  args.join(' ')
end

def delayed_job_bin
  "#{fetch(:delayed_job_bin_path)}/delayed_job"
end

def delayed_job_start_command
  "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} #{delayed_job_args} -i \#{i} start"
end

def delayed_job_stop_command
  "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} -i \#{i} stop"
end

# Watch the delayed_job processes using the build in template
namespace :eye do
  task :watch_process do

    watch_process(:delayed_job, {
      start_command: delayed_job_start_command,
      stop_command: delayed_job_stop_command
    })

  end
end

# Override start, restart and stop delayed_job tasks to so they call
# the eye equivalents
namespace :delayed_job do
  ['start','restart','stop'].each do |cmd|
    if Rake::Task.task_defined?("delayed_job:#{cmd}")
      Rake::Task["delayed_job:#{cmd}"].clear_actions
      # Reload or restart delayed_job after the application is published
      desc "using eye"
      task cmd do
        invoke "eye:#{cmd}", 'delayed-job'
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
negroku-2.7.1 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.7.0 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.6.0 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.5 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.4 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.3 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.2 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.1 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.5.0 lib/negroku/capistrano/tasks/eye/delayed_job.rake
negroku-2.4.2 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.4.1 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.4.0 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.5 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.4 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.3 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.2 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.1 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.3.0 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.2.0 lib/negroku/tasks/eye/delayed_job.rake
negroku-2.1.0 lib/negroku/tasks/eye/delayed_job.rake