Sha256: f65876a712a232cb966113d1fdeafdd119edf3037810545bf2714e210d641e57

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'capistrano/dsl/delayed_job_paths'
require 'capistrano/delayed_job/helpers'

include Capistrano::DelayedJob::Helpers
include Capistrano::DSL::DelayedJobPaths

namespace :load do
  task :defaults do
    set :delayed_job_workers, 1
    set :delayed_job_service, -> { "delayed_job_#{fetch(:application)}_#{fetch(:stage)}" }

    set :delayed_job_server_roles, [:app]
  end
end

namespace :delayed_job do

  task :defaults do
    on roles fetch(:delayed_job_server_roles) do
      set :delayed_job_user, fetch(:delayed_job_user, deploy_user)
    end
  end

  desc 'Setup DelayedJob initializer'
  task :setup do
    on roles fetch(:delayed_job_server_roles) do
      sudo_upload! dj_template('delayed_job_init.erb'), delayed_job_initd_file
      execute :chmod, '+x', delayed_job_initd_file
      sudo 'update-rc.d', '-f', fetch(:delayed_job_service), 'defaults'
    end
  end

  before :setup, :defaults

  %w[start stop restart].each do |command|
    desc "#{command} delayed_job"
    task command do
      on roles fetch(:delayed_job_server_roles) do
        sudo :service, "#{fetch(:delayed_job_service)} #{command}"
      end
    end
  end
end

namespace :deploy do
  after :publishing, 'delayed_job:restart'
end

desc 'Server setup tasks'
task :setup do
  invoke 'delayed_job:setup'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-delayed-job-1.0.1 lib/capistrano/tasks/delayed_job.rake
capistrano-delayed-job-1.0.0 lib/capistrano/tasks/delayed_job.rake