2014-10-06 84 views
4

當我部署到pre服務器時,一切都很好。但如果我嘗試部署到staging服務器我得到這個錯誤:
bundler: command not found: bin/delayed_jobRails 4,capistrano 3,delayed_job - 在其中一臺服務器上找不到bin/delayed_job

文件 - 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 

重啓延遲工作 -

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 

能否請你給我一個手在這個問題上 ?提前致謝!

更新1
有關此錯誤的信息:
lib/capistrano/tasks/delayed_job.rake:33這是execute :bundle, :exec, :'bin/delayed_job', args, :restart

回答

2

檢查,如果你能在#{deploy_to}/shared/bin/

看到的delayed_job您的臨時服務器上。如果它不存在,複製它有來自您項目的bin文件夾。

+0

這兩個地方都沒有 – Elmor 2014-10-08 12:28:33

+0

我有,但仍然沒有工作。 – monteirobrena 2015-12-10 16:31:04

6

你應該在目標服務器上運行一次:

bundle exec rails generate delayed_job 

這將在共享的/ bin中產生delayed_job的可執行腳本

+0

是否有任何理由不希望在dev中生成bin並添加到源代碼中?或者每個部署在服務器端運行生成更好嗎?謝謝, – 2016-04-04 23:31:43

+0

maxkaplan你應該在開發過程中生成這個文件並將bin文件檢入源代碼控制 – JamieD 2016-08-19 21:15:13

0

其更好地使用Capistrano的:: DelayedJob寶石

延遲工作支持Capistrano 3.x

這一行添加到您的應用程序的的Gemfile

gem 'capistrano3-delayed-job', '~> 1.0' 

要求在Capfile使用默認的任務:

require 'capistrano/delayed-job' 

添加到您的deploy.rb文件

after 'deploy:published', 'restart' do 
    invoke 'delayed_job:restart' 
end 

更多可配置選項https://github.com/platanus/capistrano3-delayed-job

2

除了Rider的回答操作。如果bin/delayed_job在那裏丟失,以下將在遠程執行'bundle exec rails generated delayed_job'。把它放在config/deploy.rb文件中。

namespace :delayed_job do 

    desc "Install Deployed Job executable if needed" 
    task :install do 
    on roles(delayed_job_roles) do |host| 
     within release_path do 
     # Only install if not already present 
     unless test("[ -f #{release_path}/#{delayed_job_bin} ]") 
      with rails_env: fetch(:rails_env) do 
      execute :bundle, :exec, :rails, :generate, :delayed_job 
      end 
     end 
     end 
    end 
    end 

    before :start, :install 
    before :restart, :install 

end 
0

發生這種情況,因爲delayed_job可執行文件缺少服務器上。它應該存在於bin目錄中。爲了解決這個問題,你應該在你的開發機器上生成可執行文件,並將它檢入源代碼控制。

該命令將生成可執行爲您提供:

bundle exec rails generate delayed_job

0

請正確檢查,如果你設置你的RAILS_ENV系統變量。

相關問題