Resque + God + Capistrano

Updated . Posted . Visible to the public.

Attached is a working config to deploy an application with Capistrano Show archive.org snapshot that needs to monitor Resque Show archive.org snapshot workers with God Show archive.org snapshot .

God will run as the deployment user, no need to register it as a system service.

Put this into your config/deploy.rb:

namespace :god do
  def god_is_running
    !capture("#{god_command} status >/dev/null 2>/dev/null || echo 'not running'").start_with?('not running')
  end

  def god_command
    "cd #{current_path}; bundle exec god"
  end

  desc "Stop god"
  task :terminate_if_running do
    if god_is_running
      run "#{god_command} terminate"
    end
  end

  desc "Start god"
  task :start do
    config_file = "#{current_path}/config/resque.god"
    environment = { :RAILS_ENV => rails_env, :RAILS_ROOT => current_path }
    run "#{god_command} -c #{config_file}", :env => environment
  end
end

before "deploy:update", "god:terminate_if_running"
after "deploy:update", "god:start"

Put the attached resque.god config into your applications config directory.

You can adjust the number of workers there.

Tobias Kraze
Last edit
Attachments
Keywords
monitoring, queue
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2011-08-02 11:24)