Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4, capistrano 3, delayed_job - can't find bin/delayed_job on one of the servers

When i deploy to pre server everything's woking fine. But if i try to deploy to staging server i get this error:
bundler: command not found: bin/delayed_job

file - config/deploy/staging.rb

set :rails_env, 'staging'  
set :eager_load, :true  
set :unicorn_rack_env, 'staging'  
role :app, %w{[email protected]}  
role :web, %w{[email protected]}  
role :db, %w{[email protected]}  

set :rvm_type, :auto                    # Defaults to: :auto  
set :rvm_ruby_version, '2.1.2'  

set :rails_env, 'staging'  
set :eager_load, :true    
role :app, %w{[email protected].}  
role :web, %w{[email protected].}  
role :db, %w{[email protected].}  
set :rvm_type, :auto                    # Defaults to: :auto  
set :rvm_ruby_version, '2.1.2'  
set :deploy_to, '/var/www/app'  
server 'x.x.x', user: 'deploy', roles: %w{web app} , port: 222  
set :unicorn_pid, ->{ "#{deploy_to}/shared/tmp/pids/unicorn.pid" }  
set :scm, :git  
set :ssh_options, { user: 'superman' }  
set :keep_releases, 5  

restart of delayed jobs -

namespace :delayed_job do  
  def args  
    fetch(:delayed_job_args, "")   
  end

  def delayed_job_roles  
    fetch(:delayed_job_server_role, :app)   
  end   

  desc 'Stop the delayed_job process'  
  task :stop do  
    on roles(delayed_job_roles) do  
      within release_path do  
        with rails_env: fetch(:rails_env) do  
          execute :bundle, :exec, :'bin/delayed_job', :stop  
        end  
      end  
    end   
  end  

  desc 'Start the delayed_job process'
  task :start do  
    on roles(delayed_job_roles) do  
      within release_path do  
        with rails_env: fetch(:rails_env) do  
          execute :bundle, :exec, :'bin/delayed_job', args, :start  
        end  
      end  
    end   
  end  

  desc 'Restart the delayed_job process'  
  task :restart do  
    on roles(delayed_job_roles) do  
      within release_path do  
        with rails_env: fetch(:rails_env) do  
          execute :bundle, :exec, :'bin/delayed_job', args, :restart  
        end  
      end  
    end   
  end  
end 

Could you please give me a hand in this issue ? Thanks in advance!

UPDATE 1
More info on this error :
lib/capistrano/tasks/delayed_job.rake:33 which is execute :bundle, :exec, :'bin/delayed_job', args, :restart

like image 876
Elmor Avatar asked Oct 06 '14 08:10

Elmor


2 Answers

You should run once on destination server:

bundle exec rails generate delayed_job

This will generate delayed_job executable script in shared/bin

like image 182
Benjamin Harel Avatar answered Oct 15 '22 01:10

Benjamin Harel


Check if you can see delayed_job on your staging server in #{deploy_to}/shared/bin/

If it's not there, copy it there from your project's bin folder.

like image 23
Tatiana Potetinova Avatar answered Oct 15 '22 01:10

Tatiana Potetinova