Skip to content

Chewy tasks and Elasticsearch indexes management with Capistrano

License

Notifications You must be signed in to change notification settings

nbulaj/capistrano-chewy

Repository files navigation

Capistrano::Chewy

Gem Version Build Status Dependency Status Code Climate

Manage and continuously rebuild your ElasticSearch indexes with Chewy and Capistrano v3.

Capistrano::Chewy gem adds automatic conditionally reset of only modified Chewy indexes and the removal of deleted index files to your deploy flow so you do not have to do it manually. Moreover, it adds the possibility of manual index management with the base Chewy tasks on the remote server.

DEPRECATED: use native Chewy rake tasks for the same purposes.

Requirements

  • Ruby >= 1.9.3
  • Capistrano >= 3.0
  • Chewy >= 0.4

Installation

Add this line to your application's Gemfile:

gem 'capistrano-chewy', require: false

or:

gem 'capistrano-chewy', require: false, group: :development

And then run bundler:

$ bundle

Or install it yourself as:

$ gem install capistrano-chewy

If you want to use the latest version from the master, then add the following line to your Gemfile:

gem 'capistrano-chewy', git: 'https://github.com/nbulaj/capistrano-chewy.git'

Usage

Require it in your Capfile:

# Capfile

...
require 'capistrano/chewy'
...

then you can use cap -T to list Capistrano::Chewy tasks:

cap chewy:rebuild            # Reset modified and delete removed Chewy indexes
cap chewy:reset              # Destroy, recreate and import data to all the indexes
cap chewy:reset[indexes]     # Destroy, recreate and import data to the specified indexes
cap chewy:update             # Updates data to all the indexes
cap chewy:update[indexes]    # Updates data to the specified indexes

By default Capistrano::Chewy adds deploy:chewy:rebuild task after deploy:updated and deploy:reverted. If you want to change it, then you need to disable default gem hooks by setting chewy_default_hooks to false in your deployment config and manually define the order of the tasks.

Configuration

You can setup the following options:

# deploy.rb
set :chewy_conditionally_reset, false    # Reset only modified Chewy indexes, true by default
set :chewy_path, 'app/my_indexes'        # Path to Chewy indexes, 'app/chewy' by default
set :chewy_env, :chewy_production        # Environment variable for Chewy, equal to RAILS_ENV by default
set :chewy_role, :web                    # Chewy role, :app by default  
set :chewy_default_hooks, false          # Add default gem hooks to project deploy flow, true by default
set :chewy_delete_removed_indexes, false # Delete indexes which files have been deleted, true by default

Contributing

You are very welcome to help improve Capistrano:Chewy if you have suggestions for features that other people can use or some code improvements.

To contribute:

  1. Fork the project( http://github.com/nbulaj/capistrano-chewy/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request