Delayed job wont start using Capistrano

前端 未结 6 1358
醉话见心
醉话见心 2021-02-04 13:14

I cannot start delayed job process using a capistrano recipe. Here\'s the error I am getting.

/usr/local/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.1/lib/delayed/         


        
相关标签:
6条回答
  • 2021-02-04 13:23

    I also got this error and found a couple of issues:

    • Ensure you have a shared/pids folder.
    • Ensure you have the correct hooks setup

    Your deploy.rb script should contain:

    require "delayed/recipes"
    
    after "deploy:stop", "delayed_job:stop"
    after "deploy:start", "delayed_job:start"
    after "deploy:restart", "delayed_job:restart"
    

    I'd copied the hooks from an old post and they appear to be incorrect now. These are from the actual delayed_job recipe file comments.

    I believe cap deploy:setup should create the pids folder but I set things up a different way and it was not created. app/current/tmp/pids links to app/shared/pids and this was causing the false directory exists error.

    0 讨论(0)
  • 2021-02-04 13:29

    Since the creation of the directories is cheap and fast, use the following callback:

    before 'deploy', 'deploy:setup'
    

    This will ensure that structure is always there before each deploy.

    0 讨论(0)
  • 2021-02-04 13:33

    Seeing the same problem.

    It turns out I was missing the ~/apps/application_name/shared/pids directory.

    Finally creating it made this problem go away.

    No need to set up custom dj_pids directory.

    0 讨论(0)
  • 2021-02-04 13:39

    This is how I fixed the issue, I passed an explicit pids dir parameter using "--pid-dir". Not sure if this is perfect, but it worked.

    task :restart, :roles => :app do
      run "cd #{current_path}; RAILS_ENV=#{rails_env} script/delayed_job -n #{dj_proc_count} --pid-dir=#{app_root}/shared/dj_pids restart"
    end
    
    0 讨论(0)
  • 2021-02-04 13:39

    I had the same issue. Turned out that there was an existing

    application_name/shared/pids/delayed_job.main.pid

    file, which had incorrect owner permissions, which was causing the deployment to fail. Fixing this file's permissions solved the issue for me.

    0 讨论(0)
  • 2021-02-04 13:43

    Add the creation of this directory before

    after "deploy:restart", "delayed_job:start"
    task :start, :roles => :app do  
      run "mkdir #{current_path}/tmp/pids"
      run "cd #{current_path}; RAILS_ENV=#{rails_env} script/delayed_job -n 2 start"
    end
    
    0 讨论(0)
提交回复
热议问题