Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 903055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:48:53+00:00 2026-05-15T15:48:53+00:00

I have Thinking Sphinx setup and working however I am having a problem getting

  • 0

I have Thinking Sphinx setup and working however I am having a problem getting the Delayed Job rake tasks to start during deployment.

I have the following task in deploy.rb which appears to execute, however the delayed jobs are not processed – they stack up until I run rake ts:dd from the server command line:

namespace :thinkingsphinx do
  desc 'Start Delayed Job Sphinx delta indexing'
  task :dd do
    run "cd #{current_path} && rake ts:dd RAILS_ENV=#{rails_env} &" 
  end
end

How can I get the delayed jobs to start running from the deployment script?

Thanks

Simon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:48:54+00:00Added an answer on May 15, 2026 at 3:48 pm

    The link Florian provided has code by Amit Solanki that works!

    Here is what I did to get this to work with Capistrano:

    Install gems

    • ts-delayed-delta
    • daemon_generator
    • whenever

    Create a file called script/delayed_delta with the contents:

    #!/usr/bin/env ruby
    require 'rubygems'
    require 'daemons'
    dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
    
    daemon_options = {
      :multiple => false,
      :dir_mode => :normal,
      :dir => File.join(dir, 'tmp', 'pids'),
      :backtrace => true
    }
    puts 'delayed_delta'
    
    Daemons.run_proc('job_runner', daemon_options) do
      if ARGV.include?('--')
        ARGV.slice! 0..ARGV.index('--')
      else
        ARGV.clear
      end
    
      Dir.chdir dir
      RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development'
      require File.join('config', 'environment')
    
      Delayed::Worker.new(
        :min_priority => ENV['MIN_PRIORITY'],
        :max_priority => ENV['MAX_PRIORITY']
      ).start
    end
    

    Configure Capistrano

    Capistrano needs to start Sphinx and job_runner (with our script/delayed_delta).

    Add something like this to the deploy.rb:

    deploy.task :restart, :roles => :app do
      run "export RAILS_ENV=production && cd #{deploy_to}/current && /usr/bin/rake ts:rebuild"  
      run "export RAILS_ENV=production && cd #{current_path} && /usr/bin/ruby script/delayed_delta start"
    end
    

    Configure whenever gem

    In your config/schedule.rb add lines to update Sphinx’s index and start job_runner if it isn’t already running

    every 30.minutes do
      command "export RAILS_ENV=production && cd /path/to/rails/production && /usr/bin/rake ts:index && /usr/bin/ruby script/delayed_delta start"
    end
    

    This gets converted to a crontab that is run every 30 minutes to update sphinx

    Final Notes and Lessons Learned

    • The script/delayed_delta uses the daemon_generator gem to start the job_runner background worker script. This is equivalent to running rake thinking_sphinx:delayed_deltas on the console, but persistent.

    • Make sure only one job_runner or rake thinking_sphinx:delayed_deltas process is running at one time

    • Let Capistrano start both Sphinx (rake ts:rebuild) and script/delayed_delta. I had problem when I started sphinx and delayed_deltas from different users or different environments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to get Thinking Sphinx working w/ Delayed Jobs but I am not
I have successfully got Thinking Sphinx working with Geolocation on an associated model. Happy
I have serious problem with Thinking Sphinx in my Rails application. My app specifications
I have Ruby on Rails 3.1 application and i use for Sphinx + Thinking
I have been thinking about a way solve a problem I have and I'm
I'm working on a toy game engine. I have never been thinking about coordinate
I have Sphinx and Thinking Sphinx 2.0.5 installed on my application and when I
The error I'm getting with the thinking-sphinx 2.1.0 gem is: Sphinx cannot be found
I have a thinking-sphinx app and oddly enough the files in /db/sphinx/development/ have not
I have a Technique model which belongs_to User and is indexed by Thinking Sphinx.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.